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;
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);
}
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);