sched: Make the outbuf table local to run()

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2017-09-14 14:37:10 -04:00
parent ba08f8a4ed
commit e0984b8a51

View File

@ -85,8 +85,6 @@ outbuf_table_ent_eq(const outbuf_table_ent_t *a, const outbuf_table_ent_t *b)
return a->chan->global_identifier == b->chan->global_identifier;
}
static outbuf_table_t outbuf_table = HT_INITIALIZER();
HT_PROTOTYPE(outbuf_table_s, outbuf_table_ent_s, node, outbuf_table_ent_hash,
outbuf_table_ent_eq)
HT_GENERATE2(outbuf_table_s, outbuf_table_ent_s, node, outbuf_table_ent_hash,
@ -145,13 +143,6 @@ free_outbuf_info_by_ent(outbuf_table_ent_t *ent, void *data)
return 1; /* So HT_FOREACH_FN will remove the element */
}
/* Clean up outbuf_table. Probably because the KIST sched impl is going away */
static void
free_all_outbuf_info(void)
{
HT_FOREACH_FN(outbuf_table_s, &outbuf_table, free_outbuf_info_by_ent, NULL);
}
/* Free the given socket table entry ent. */
static int
free_socket_info_by_ent(socket_table_ent_t *ent, void *data)
@ -425,7 +416,6 @@ have_work(void)
static void
kist_free_all(void)
{
free_all_outbuf_info();
free_all_socket_info();
}
@ -508,6 +498,8 @@ kist_scheduler_run(void)
smartlist_t *to_readd = NULL;
smartlist_t *cp = get_channels_pending();
outbuf_table_t outbuf_table = HT_INITIALIZER();
/* For each pending channel, collect new kernel information */
SMARTLIST_FOREACH_BEGIN(cp, const channel_t *, pchan) {
init_socket_info(&socket_table, pchan);
@ -618,7 +610,8 @@ kist_scheduler_run(void)
/* Write the outbuf of any channels that still have data */
HT_FOREACH_FN(outbuf_table_s, &outbuf_table, each_channel_write_to_kernel,
NULL);
free_all_outbuf_info();
/* We are done with it. */
HT_FOREACH_FN(outbuf_table_s, &outbuf_table, free_outbuf_info_by_ent, NULL);
HT_CLEAR(outbuf_table_s, &outbuf_table);
log_debug(LD_SCHED, "len pending=%d, len to_readd=%d",