diff options
Diffstat (limited to 'ffd/ack.c')
-rw-r--r-- | ffd/ack.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -40,6 +40,7 @@ static uint16_t nonce = 0; typedef struct _ack_arg_t { void (*cb)(uint16_t nonce, void *arg); + void (*free)(uint16_t nonce, void *arg); void *arg; uint16_t nonce; @@ -56,6 +57,7 @@ static void ack_resend(const struct timespec *timeout, void *argp) { ack_arg_t *arg = argp; if (GET_ACK(arg->nonce) || !(--arg->retries)) { + arg->free(arg->nonce, arg->arg); free(arg); return; } @@ -65,12 +67,13 @@ static void ack_resend(const struct timespec *timeout, void *argp) { ffd_queue_put_delayed(&ack_requests, ack_resend, timeout, arg->interval, arg); } -void ffd_ack_request(void (*cb)(uint16_t nonce, void *arg), unsigned interval, unsigned retries, void *arg) { +void ffd_ack_request(void (*cb)(uint16_t nonce, void *arg), void (*free_cb)(uint16_t nonce, void *arg), unsigned interval, unsigned retries, void *arg) { UNSET_ACK(nonce); cb(nonce, arg); ack_arg_t *ack_arg = malloc(sizeof(ack_arg_t)); ack_arg->cb = cb; + ack_arg->free = free_cb; ack_arg->arg = arg; ack_arg->nonce = nonce++; ack_arg->interval = interval; |