diff options
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/DatabaseLock.hxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/db/DatabaseLock.hxx b/src/db/DatabaseLock.hxx index 786c97899..253eb73fb 100644 --- a/src/db/DatabaseLock.hxx +++ b/src/db/DatabaseLock.hxx @@ -84,13 +84,26 @@ db_unlock(void) } class ScopeDatabaseLock { + bool locked = true; + public: ScopeDatabaseLock() { db_lock(); } ~ScopeDatabaseLock() { + if (locked) + db_unlock(); + } + + /** + * Unlock the mutex now, making the destructor a no-op. + */ + void unlock() { + assert(locked); + db_unlock(); + locked = false; } }; |