|
xapian-core
2.0.0
|
#include <flint_lock.h>
Collaboration diagram for FlintLock:Public Types | |
| enum | reason { SUCCESS , INUSE , UNSUPPORTED , FDLIMIT , UNKNOWN } |
Public Member Functions | |
| FlintLock (const std::string &filename_) | |
| Standard constructor. More... | |
| FlintLock () | |
| Constructor for use in read-only cases (like single-file glass). More... | |
| operator bool () const | |
| ~FlintLock () | |
| bool | test () const |
| Test if the lock is held. More... | |
| reason | lock (bool exclusive, bool wait, std::string &explanation) |
| Attempt to obtain the lock. More... | |
| void | release () |
| Release the lock. More... | |
| void | throw_databaselockerror (FlintLock::reason why, const std::string &db_dir, const std::string &explanation) const |
| Throw Xapian::DatabaseLockError. More... | |
Private Attributes | |
| std::string | filename |
| int | fd = -1 |
| pid_t | pid |
Definition at line 36 of file flint_lock.h.
| enum FlintLock::reason |
| Enumerator | |
|---|---|
| SUCCESS | |
| INUSE | |
| UNSUPPORTED | |
| FDLIMIT | |
| UNKNOWN | |
Definition at line 48 of file flint_lock.h.
|
inlineexplicit |
|
inline |
Constructor for use in read-only cases (like single-file glass).
Definition at line 66 of file flint_lock.h.
|
inline |
Definition at line 77 of file flint_lock.h.
References release().
| FlintLock::reason FlintLock::lock | ( | bool | exclusive, |
| bool | wait, | ||
| std::string & | explanation | ||
| ) |
Attempt to obtain the lock.
If the attempt fails with code "UNKNOWN", the string supplied in the explanation parameter will be set to contain any details available of the reason for the failure.
| exclusive | Get an exclusive lock? Value currently ignored, and the lock is always exclusive. |
| wait | Wait until we can get the lock? |
Definition at line 124 of file flint_lock.cc.
References Assert, close(), Xapian::Internal::closefrom(), errno_to_string(), O_CLOEXEC, Xapian::Remote::open(), rare, SOCK_CLOEXEC, and usual.
Referenced by GlassDatabaseReplicator::apply_changeset_from_conn(), GlassDatabase::compact(), HoneyDatabase::compact(), and GlassDatabase::get_database_write_lock().
|
inline |
Definition at line 68 of file flint_lock.h.
References fd.
| void FlintLock::release | ( | ) |
Release the lock.
Definition at line 458 of file flint_lock.cc.
References close().
Referenced by GlassDatabase::close(), GlassDatabase::compact(), HoneyDatabase::compact(), and ~FlintLock().
| bool FlintLock::test | ( | ) | const |
Test if the lock is held.
If this object holds the lock, just returns true. Otherwise it will try to test taking the lock, if that is possible to do on the current platform without actually take it (fcntl() locks support this).
Throws Xapian::UnimplemenetedError if the platform doesn't support testing the lock in this way, or Xapian::DatabaseLockError if there's an error while trying to perform the test.
Definition at line 74 of file flint_lock.cc.
References close(), O_CLOEXEC, Xapian::Remote::open(), and throw_cannot_test_lock().
Referenced by GlassDatabase::locked().
| void FlintLock::throw_databaselockerror | ( | FlintLock::reason | why, |
| const std::string & | db_dir, | ||
| const std::string & | explanation | ||
| ) | const |
Throw Xapian::DatabaseLockError.
Definition at line 494 of file flint_lock.cc.
References FDLIMIT, INUSE, UNKNOWN, and UNSUPPORTED.
Referenced by GlassDatabaseReplicator::apply_changeset_from_conn(), GlassDatabase::compact(), HoneyDatabase::compact(), and GlassDatabase::get_database_write_lock().
|
private |
Definition at line 43 of file flint_lock.h.
Referenced by operator bool().
|
private |
Definition at line 37 of file flint_lock.h.
Referenced by FlintLock().
|
private |
Definition at line 44 of file flint_lock.h.