lightningd/msg_queue: add msg_wake helper.

A cleaner wrapper than a raw io_wake.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-04-12 09:10:10 -07:00 committed by Christian Decker
parent d967c2ba64
commit a436fa77fc
3 changed files with 12 additions and 4 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -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);