From 240abf6c46779e0cf4d718d14d96fe8bf5b68470 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 19 Oct 2018 11:47:48 +1030 Subject: [PATCH] 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 --- common/io_lock.c | 5 +++++ common/io_lock.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/common/io_lock.c b/common/io_lock.c index 5c35edba7..d32a510d0 100644 --- a/common/io_lock.c +++ b/common/io_lock.c @@ -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; +} diff --git a/common/io_lock.h b/common/io_lock.h index 47b84ccd3..a1130d854 100644 --- a/common/io_lock.h +++ b/common/io_lock.h @@ -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 */