Introduce fish_mutex_t wrapping std::mutex

Add a fish-specific wrapper around std::mutex that records whether it is
locked in a bool. This is to make ASSERT_IS_LOCKED() simpler (it can just
check the boolean instead of relying on try_lock) which will make Coverity
Scan happier.

Some details: Coverity Scan was complaining about an apparent double-unlock
because it's unaware of the semantics of try_lock(). Specifically fish
asserts that a lock is locked by asserting that try_lock fails; if it
succeeds fish prints an error and then unlocks the lock (so as not to leave
it locked). This unlock is of course correct, but it confused Coverity Scan.
This commit is contained in:
ridiculousfish
2018-02-08 21:59:52 -08:00
parent 8069939112
commit 3a45cad12e
9 changed files with 47 additions and 23 deletions

View File

@@ -162,7 +162,7 @@ class variable_entry_t {
wcstring value; /**< Value of the variable */
};
static std::mutex env_lock;
static fish_mutex_t env_lock;
static bool local_scope_exports(const env_node_t *n);