mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
Migrating daemon_conn to msg_queue and msg_queue takes over messages
We have some duplication in handling queues, so this is an attempt at deduplicating some of that work. `daemon_conn` now uses the `msg_queue` and `channeld` was also migrated to `msg_queue`. At the same time I made `msg_queue` create a copy of the messages or takes over messages marked with `take()`. This should make cleaning up messages easier.
This commit is contained in:
@@ -3,13 +3,14 @@
|
||||
void msg_queue_init(struct msg_queue *q, const tal_t *ctx)
|
||||
{
|
||||
q->q = tal_arr(ctx, const u8 *, 0);
|
||||
q->ctx = ctx;
|
||||
}
|
||||
|
||||
void msg_enqueue(struct msg_queue *q, const u8 *add)
|
||||
{
|
||||
size_t n = tal_count(q->q);
|
||||
tal_resize(&q->q, n+1);
|
||||
q->q[n] = add;
|
||||
q->q[n] = tal_dup_arr(q->ctx, u8, add, tal_len(add), 0);
|
||||
|
||||
/* In case someone is waiting */
|
||||
io_wake(q);
|
||||
|
||||
Reference in New Issue
Block a user