mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
lightningd: allow subd_req() to take replycb_data arg.
Useful if it's only to be used for the duration of the callback. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
658cc9db5f
commit
77fdd63c50
2 changed files with 6 additions and 4 deletions
|
@ -142,13 +142,15 @@ static struct subd_req *add_req(const tal_t *ctx,
|
|||
struct subd *sd, int type, size_t num_fds_in,
|
||||
void (*replycb)(struct subd *, const u8 *, const int *,
|
||||
void *),
|
||||
void *replycb_data)
|
||||
void *replycb_data TAKES)
|
||||
{
|
||||
struct subd_req *sr = tal(sd, struct subd_req);
|
||||
|
||||
sr->type = type;
|
||||
sr->replycb = replycb;
|
||||
sr->replycb_data = replycb_data;
|
||||
if (taken(replycb_data))
|
||||
tal_steal(sr, replycb_data);
|
||||
sr->num_reply_fds = num_fds_in;
|
||||
|
||||
/* We don't allocate sr off ctx, because we still have to handle the
|
||||
|
@ -852,7 +854,7 @@ struct subd_req *subd_req_(const tal_t *ctx,
|
|||
const u8 *msg_out,
|
||||
int fd_out, size_t num_fds_in,
|
||||
void (*replycb)(struct subd *, const u8 *, const int *, void *),
|
||||
void *replycb_data)
|
||||
void *replycb_data TAKES)
|
||||
{
|
||||
/* Grab type now in case msg_out is taken() */
|
||||
int type = fromwire_peektype(msg_out);
|
||||
|
|
|
@ -178,7 +178,7 @@ void subd_send_fd(struct subd *sd, int fd);
|
|||
* @fd_out: if >=0 fd to pass at the end of the message (closed after)
|
||||
* @num_fds_in: how many fds to read in to hand to @replycb if it's a reply.
|
||||
* @replycb: callback (inside db transaction) when reply comes in (can free subd)
|
||||
* @replycb_data: final arg to hand to @replycb
|
||||
* @replycb_data: final arg to hand to @replycb (can be TAKE())
|
||||
*
|
||||
* @replycb cannot free @sd, so it returns false to remove it.
|
||||
* Note that @replycb is called for replies of type @msg_out + SUBD_REPLY_OFFSET
|
||||
|
@ -196,7 +196,7 @@ struct subd_req *subd_req_(const tal_t *ctx,
|
|||
const u8 *msg_out,
|
||||
int fd_out, size_t num_fds_in,
|
||||
void (*replycb)(struct subd *, const u8 *, const int *, void *),
|
||||
void *replycb_data);
|
||||
void *replycb_data TAKES);
|
||||
|
||||
/**
|
||||
* subd_release_channel - shut down a subdaemon which no longer owns the channel.
|
||||
|
|
Loading…
Add table
Reference in a new issue