From a436fa77fc2e7ce8703a0ba2f1eb006ebc60e55a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 12 Apr 2017 09:10:10 -0700 Subject: [PATCH] lightningd/msg_queue: add msg_wake helper. A cleaner wrapper than a raw io_wake. Signed-off-by: Rusty Russell --- lightningd/gossip/gossip.c | 4 ++-- lightningd/msg_queue.c | 5 +++++ lightningd/msg_queue.h | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lightningd/gossip/gossip.c b/lightningd/gossip/gossip.c index 863930cec..35168c68e 100644 --- a/lightningd/gossip/gossip.c +++ b/lightningd/gossip/gossip.c @@ -237,9 +237,9 @@ static void wake_pkt_out(struct peer *peer) new_reltimer(&peer->daemon->timers, peer, time_from_sec(30), wake_pkt_out, peer); /* Notify the peer-write loop */ - io_wake(&peer->peer_out); + msg_wake(&peer->peer_out); /* Notify the daemon_conn-write loop */ - io_wake(&peer->owner_conn.out); + msg_wake(&peer->owner_conn.out); } static struct io_plan *peer_pkt_out(struct io_conn *conn, struct peer *peer) diff --git a/lightningd/msg_queue.c b/lightningd/msg_queue.c index 9e7553e53..7a341b87b 100644 --- a/lightningd/msg_queue.c +++ b/lightningd/msg_queue.c @@ -57,3 +57,8 @@ int msg_extract_fd(const u8 *msg) return fromwire_u32(&p, &len); } + +void msg_wake(const struct msg_queue *q) +{ + io_wake(q); +} diff --git a/lightningd/msg_queue.h b/lightningd/msg_queue.h index 46e010a3e..720bc53b5 100644 --- a/lightningd/msg_queue.h +++ b/lightningd/msg_queue.h @@ -15,12 +15,15 @@ struct msg_queue { void msg_queue_init(struct msg_queue *q, const tal_t *ctx); -/* If add is taken(), freed after sending. */ +/* If add is taken(), freed after sending. msg_wake() implied. */ void msg_enqueue(struct msg_queue *q, const u8 *add); -/* Fd is closed after sending. */ +/* Fd is closed after sending. msg_wake() implied. */ void msg_enqueue_fd(struct msg_queue *q, int fd); +/* Explicitly wake up a msg_queue_wait */ +void msg_wake(const struct msg_queue *q); + /* Returns NULL if nothing to do. */ const u8 *msg_dequeue(struct msg_queue *q);