common/io_lock: add helper to query if lock is taken.

Not just for debugging; we actually need to know if a write is active for
the coming hack.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-10-19 11:47:48 +10:30
parent e46ce0fc84
commit 240abf6c46
2 changed files with 10 additions and 0 deletions

View File

@@ -80,3 +80,8 @@ void io_lock_release(struct io_lock *lock)
lock->locked = false;
io_wake(lock);
}
bool io_lock_taken(const struct io_lock *lock)
{
return lock->locked;
}

View File

@@ -47,4 +47,9 @@ struct io_plan *io_lock_acquire_in_(struct io_conn *conn, struct io_lock *lock,
*/
void io_lock_release(struct io_lock *lock);
/**
* Is this lock acquired?
*/
bool io_lock_taken(const struct io_lock *lock);
#endif /* LIGHTNING_COMMON_IO_LOCK_H */