0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 02:01:55 +00:00

Channel feeding request has a done-hook

This commit is contained in:
Maria Matejka 2023-10-04 10:02:43 +02:00
parent 843bd05087
commit 5e733a764d
2 changed files with 20 additions and 14 deletions

View File

@ -759,8 +759,7 @@ channel_feed_end(struct channel *c)
for (struct channel_feeding_request *cfr = c->refeeding, *next = cfr ? cfr->next : NULL; for (struct channel_feeding_request *cfr = c->refeeding, *next = cfr ? cfr->next : NULL;
cfr; cfr;
(cfr = next), (next = next ? next->next : NULL)) (cfr = next), (next = next ? next->next : NULL))
if (cfr->flags & CFRF_DYNAMIC) CALL(cfr->done, cfr);
mb_free(cfr);
/* Drop the refeed batch */ /* Drop the refeed batch */
c->refeeding = NULL; c->refeeding = NULL;
@ -1010,12 +1009,21 @@ channel_request_feeding(struct channel *c, struct channel_feeding_request *cfr)
channel_init_feeding(c); channel_init_feeding(c);
} }
static void
channel_feeding_request_done_dynamic(struct channel_feeding_request *req)
{
mb_free(req);
}
void void
channel_request_feeding_dynamic(struct channel *c, enum channel_feeding_request_type type) channel_request_feeding_dynamic(struct channel *c, enum channel_feeding_request_type type)
{ {
struct channel_feeding_request *req = mb_allocz(c->proto->pool, sizeof *req); struct channel_feeding_request *req = mb_alloc(c->proto->pool, sizeof *req);
req->type = type; *req = (struct channel_feeding_request) {
req->flags |= CFRF_DYNAMIC; .type = type,
.done = channel_feeding_request_done_dynamic,
};
channel_request_feeding(c, req); channel_request_feeding(c, req);
} }

View File

@ -676,19 +676,17 @@ static inline void channel_open(struct channel *c) { channel_set_state(c, CS_UP)
static inline void channel_close(struct channel *c) { channel_set_state(c, CS_STOP); } static inline void channel_close(struct channel *c) { channel_set_state(c, CS_STOP); }
struct channel_feeding_request { struct channel_feeding_request {
struct channel_feeding_request *next; struct channel_feeding_request *next; /* Next in request chain */
void (*done)(struct channel_feeding_request *); /* Called when refeed finishes */
PACKED enum channel_feeding_request_type { PACKED enum channel_feeding_request_type {
CFRT_DIRECT = 1, CFRT_DIRECT = 1, /* Refeed by export restart */
CFRT_AUXILIARY, CFRT_AUXILIARY, /* Refeed by auxiliary request */
} type; } type;
PACKED enum { PACKED enum {
CFRS_INACTIVE = 0, CFRS_INACTIVE = 0, /* Inactive request */
CFRS_PENDING, CFRS_PENDING, /* Request enqueued, do not touch */
CFRS_RUNNING, CFRS_RUNNING, /* Request active, do not touch */
} state; } state;
PACKED enum {
CFRF_DYNAMIC = 1,
} flags;
}; };
struct channel *channel_from_export_request(struct rt_export_request *req); struct channel *channel_from_export_request(struct rt_export_request *req);