comparison OrthancServer/Plugins/Engine/OrthancPluginDatabase.h @ 4594:d494b4f1103e db-changes

removed the global database mutex from ServerIndex and StatelessDatabaseOperations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 16 Mar 2021 12:43:43 +0100
parents 60a860942c5e
children cc64385593ef
comparison
equal deleted inserted replaced
4593:60a860942c5e 4594:d494b4f1103e
42 #include "../../Sources/Database/Compatibility/ILookupResourceAndParent.h" 42 #include "../../Sources/Database/Compatibility/ILookupResourceAndParent.h"
43 #include "../../Sources/Database/Compatibility/ISetResourcesContent.h" 43 #include "../../Sources/Database/Compatibility/ISetResourcesContent.h"
44 #include "../Include/orthanc/OrthancCDatabasePlugin.h" 44 #include "../Include/orthanc/OrthancCDatabasePlugin.h"
45 #include "PluginsErrorDictionary.h" 45 #include "PluginsErrorDictionary.h"
46 46
47 #include <boost/thread/recursive_mutex.hpp>
48
47 namespace Orthanc 49 namespace Orthanc
48 { 50 {
51 /**
52 * This class is for backward compatibility with database plugins
53 * that don't use the primitives introduced in Orthanc 1.10.0 to
54 * deal with concurrent read-only transactions.
55 *
56 * In Orthanc <= 1.9.1, Orthanc assumed that at most 1 single thread
57 * was accessing the database plugin at anytime, in order to match
58 * the SQLite model. Read-write accesses assumed the plugin to run
59 * the SQL statement "START TRANSACTION SERIALIZABLE" so as to be
60 * able to rollback the modifications. Read-only accesses didn't
61 * start a transaction, as they were protected by the global mutex.
62 **/
49 class OrthancPluginDatabase : public IDatabaseWrapper 63 class OrthancPluginDatabase : public IDatabaseWrapper
50 { 64 {
51 private: 65 private:
52 class Transaction; 66 class Transaction;
53 67
68 /**
69 * We need a "recursive_mutex" because of "AnswerReceived()" that
70 * is called by the "answer" primitives of the database SDK once a
71 * transaction is running.
72 **/
73 boost::recursive_mutex mutex_;
74
54 SharedLibrary& library_; 75 SharedLibrary& library_;
55 PluginsErrorDictionary& errorDictionary_; 76 PluginsErrorDictionary& errorDictionary_;
56 OrthancPluginDatabaseBackend backend_; 77 OrthancPluginDatabaseBackend backend_;
57 OrthancPluginDatabaseExtensions extensions_; 78 OrthancPluginDatabaseExtensions extensions_;
58 void* payload_; 79 void* payload_;
75 size_t extensionsSize, 96 size_t extensionsSize,
76 void *payload); 97 void *payload);
77 98
78 virtual void Open() ORTHANC_OVERRIDE; 99 virtual void Open() ORTHANC_OVERRIDE;
79 100
80 virtual void Close() ORTHANC_OVERRIDE 101 virtual void Close() ORTHANC_OVERRIDE;
81 {
82 CheckSuccess(backend_.close(payload_));
83 }
84 102
85 const SharedLibrary& GetSharedLibrary() const 103 const SharedLibrary& GetSharedLibrary() const
86 { 104 {
87 return library_; 105 return library_;
88 } 106 }