mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
CLI: show threads all crash fixed
When socket dropped before finished, it failed to cleanup.
This commit is contained in:
parent
28b0adc15f
commit
6e940c259d
@ -337,12 +337,18 @@ extern cli *cmd_reconfig_stored_cli;
|
|||||||
void
|
void
|
||||||
cli_free(cli *c)
|
cli_free(cli *c)
|
||||||
{
|
{
|
||||||
CALL(c->cleanup, c);
|
bool done = c->cleanup ? c->cleanup(c) : true;
|
||||||
|
|
||||||
if (c == cmd_reconfig_stored_cli)
|
if (c == cmd_reconfig_stored_cli)
|
||||||
cmd_reconfig_stored_cli = NULL;
|
cmd_reconfig_stored_cli = NULL;
|
||||||
|
|
||||||
|
if (done)
|
||||||
rp_free(c->pool);
|
rp_free(c->pool);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sk_close(c->sock);
|
||||||
|
c->sock = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,9 @@ typedef struct cli {
|
|||||||
struct cli_out *tx_buf, *tx_pos, *tx_write;
|
struct cli_out *tx_buf, *tx_pos, *tx_write;
|
||||||
event *event;
|
event *event;
|
||||||
void (*cont)(struct cli *c);
|
void (*cont)(struct cli *c);
|
||||||
void (*cleanup)(struct cli *c); /* The CLI has closed prematurely */
|
bool (*cleanup)(struct cli *c); /* The CLI has closed prematurely; if done, return true,
|
||||||
|
otherwise return false and call rp_free(c->pool) later yourself.
|
||||||
|
The socket is closed anyway, tho. */
|
||||||
void *rover; /* Private to continuation routine */
|
void *rover; /* Private to continuation routine */
|
||||||
struct config *main_config; /* Main config currently in use */
|
struct config *main_config; /* Main config currently in use */
|
||||||
int last_reply;
|
int last_reply;
|
||||||
|
@ -225,7 +225,7 @@ rt_show_net(struct rt_show_data *d, const struct rt_export_feed *feed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
rt_show_cleanup(struct cli *c)
|
rt_show_cleanup(struct cli *c)
|
||||||
{
|
{
|
||||||
struct rt_show_data *d = c->rover;
|
struct rt_show_data *d = c->rover;
|
||||||
@ -241,6 +241,9 @@ rt_show_cleanup(struct cli *c)
|
|||||||
|
|
||||||
/* Unreference the config */
|
/* Unreference the config */
|
||||||
OBSREF_CLEAR(d->running_on_config);
|
OBSREF_CLEAR(d->running_on_config);
|
||||||
|
|
||||||
|
/* Everything cleaned up */
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -760,11 +760,12 @@ mrt_dump_cont(struct cli *c)
|
|||||||
return mrt_table_dump_step(c->rover);
|
return mrt_table_dump_step(c->rover);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static bool
|
||||||
mrt_dump_cleanup(struct cli *c)
|
mrt_dump_cleanup(struct cli *c)
|
||||||
{
|
{
|
||||||
mrt_table_dump_free(c->rover);
|
mrt_table_dump_free(c->rover);
|
||||||
c->rover = NULL;
|
c->rover = NULL;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1259,10 +1259,11 @@ bird_thread_show_cli_cont(struct cli *c UNUSED)
|
|||||||
/* Explicitly do nothing to prevent CLI from trying to parse another command. */
|
/* Explicitly do nothing to prevent CLI from trying to parse another command. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
bird_thread_show_cli_cleanup(struct cli *c UNUSED)
|
bird_thread_show_cli_cleanup(struct cli *c UNUSED)
|
||||||
{
|
{
|
||||||
return 1; /* Defer the cleanup until the writeout is finished. */
|
/* Defer the cleanup until the writeout is finished. */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1328,6 +1329,14 @@ cmd_show_threads_done(struct bird_thread_syncer *sync)
|
|||||||
SKIP_BACK_DECLARE(struct bird_thread_show_data, tsd, sync, sync);
|
SKIP_BACK_DECLARE(struct bird_thread_show_data, tsd, sync, sync);
|
||||||
ASSERT_DIE(birdloop_inside(&main_birdloop));
|
ASSERT_DIE(birdloop_inside(&main_birdloop));
|
||||||
|
|
||||||
|
/* The client lost their patience and dropped the session early. */
|
||||||
|
if (!tsd->cli->sock)
|
||||||
|
{
|
||||||
|
mb_free(tsd);
|
||||||
|
rp_free(tsd->cli->pool);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tsd->cli->cont = NULL;
|
tsd->cli->cont = NULL;
|
||||||
tsd->cli->cleanup = NULL;
|
tsd->cli->cleanup = NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user