Skip to content
Snippets Groups Projects
Commit 661d2b43 authored by Marco Biasini's avatar Marco Biasini
Browse files

open compound lib in read-only mode, unless explicitly stated

avoids dead-locking when several processes try to open the
compound lib at the same time.
parent 1648d0c9
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ void export_Compound() {
register_ptr_to_python<CompoundPtr>();
class_<CompoundLib>("CompoundLib", no_init)
.def("Load", &CompoundLib::Load).staticmethod("Load")
.def("Load", &CompoundLib::Load, arg("readonly")=true).staticmethod("Load")
.def("FindCompound", &CompoundLib::FindCompound)
.def("ClearCache", &CompoundLib::ClearCache)
;
......
......@@ -237,10 +237,11 @@ CompoundLibPtr CompoundLib::Create(const String& database)
}
CompoundLibPtr CompoundLib::Load(const String& database)
CompoundLibPtr CompoundLib::Load(const String& database, bool readonly)
{
int flags=readonly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE;
CompoundLibPtr lib(new CompoundLib);
int retval=sqlite3_open(database.c_str(), &lib->conn_);
int retval=sqlite3_open_v2(database.c_str(), &lib->conn_, flags, NULL);
if (SQLITE_OK==retval) {
return lib;
}
......
......@@ -37,7 +37,7 @@ typedef std::map<String, CompoundPtr> CompoundMap;
class DLLEXPORT_OST_CONOP CompoundLib {
public:
static CompoundLibPtr Load(const String& database);
static CompoundLibPtr Load(const String& database, bool readonly=true);
static CompoundLibPtr Create(const String& database);
~CompoundLib();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment