mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Channel feeding request has a done-hook
This commit is contained in:
parent
843bd05087
commit
5e733a764d
18
nest/proto.c
18
nest/proto.c
@ -759,8 +759,7 @@ channel_feed_end(struct channel *c)
|
||||
for (struct channel_feeding_request *cfr = c->refeeding, *next = cfr ? cfr->next : NULL;
|
||||
cfr;
|
||||
(cfr = next), (next = next ? next->next : NULL))
|
||||
if (cfr->flags & CFRF_DYNAMIC)
|
||||
mb_free(cfr);
|
||||
CALL(cfr->done, cfr);
|
||||
|
||||
/* Drop the refeed batch */
|
||||
c->refeeding = NULL;
|
||||
@ -1010,12 +1009,21 @@ channel_request_feeding(struct channel *c, struct channel_feeding_request *cfr)
|
||||
channel_init_feeding(c);
|
||||
}
|
||||
|
||||
static void
|
||||
channel_feeding_request_done_dynamic(struct channel_feeding_request *req)
|
||||
{
|
||||
mb_free(req);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
req->type = type;
|
||||
req->flags |= CFRF_DYNAMIC;
|
||||
struct channel_feeding_request *req = mb_alloc(c->proto->pool, sizeof *req);
|
||||
*req = (struct channel_feeding_request) {
|
||||
.type = type,
|
||||
.done = channel_feeding_request_done_dynamic,
|
||||
};
|
||||
|
||||
channel_request_feeding(c, req);
|
||||
}
|
||||
|
||||
|
@ -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); }
|
||||
|
||||
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 {
|
||||
CFRT_DIRECT = 1,
|
||||
CFRT_AUXILIARY,
|
||||
CFRT_DIRECT = 1, /* Refeed by export restart */
|
||||
CFRT_AUXILIARY, /* Refeed by auxiliary request */
|
||||
} type;
|
||||
PACKED enum {
|
||||
CFRS_INACTIVE = 0,
|
||||
CFRS_PENDING,
|
||||
CFRS_RUNNING,
|
||||
CFRS_INACTIVE = 0, /* Inactive request */
|
||||
CFRS_PENDING, /* Request enqueued, do not touch */
|
||||
CFRS_RUNNING, /* Request active, do not touch */
|
||||
} state;
|
||||
PACKED enum {
|
||||
CFRF_DYNAMIC = 1,
|
||||
} flags;
|
||||
};
|
||||
|
||||
struct channel *channel_from_export_request(struct rt_export_request *req);
|
||||
|
Loading…
Reference in New Issue
Block a user