mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
lightningd/msg_queue: support queueing/dequeueing of fds.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
#include <ccan/io/io.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
|
||||
/* Reserved type used to indicate we're actually passing an fd. */
|
||||
#define MSG_PASS_FD 0xFFFF
|
||||
|
||||
struct msg_queue {
|
||||
const u8 **q;
|
||||
const tal_t *ctx;
|
||||
@@ -12,10 +15,18 @@ struct msg_queue {
|
||||
|
||||
void msg_queue_init(struct msg_queue *q, const tal_t *ctx);
|
||||
|
||||
/* If add is taken(), freed after sending. */
|
||||
void msg_enqueue(struct msg_queue *q, const u8 *add);
|
||||
|
||||
/* Fd is closed after sending. */
|
||||
void msg_enqueue_fd(struct msg_queue *q, int fd);
|
||||
|
||||
/* Returns NULL if nothing to do. */
|
||||
const u8 *msg_dequeue(struct msg_queue *q);
|
||||
|
||||
/* Returns -1 if not an fd: close after sending. */
|
||||
int msg_is_fd(const u8 *msg);
|
||||
|
||||
#define msg_queue_wait(conn, q, next, arg) \
|
||||
io_out_wait((conn), (q), (next), (arg))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user