summaryrefslogtreecommitdiff
path: root/nest/cli.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-01-19 10:53:09 +0100
committerMaria Matejka <mq@ucw.cz>2023-01-19 11:03:31 +0100
commit59a5bf18f997e11a3e3ddd70d59f597f77fa2b6c (patch)
treef0a4640ffb2f812a872a44fd512e7ba981fd09c2 /nest/cli.c
parent34aeafbf9ea98c8644f6403b3810ff0490350465 (diff)
CLI closing fix when its action is run asynchronously.
Some CLI actions, notably "show route", are run by queuing an event somewhere else. If the user closes the socket, in case such an action is being executed, the CLI must free the socket immediately from the error hook but the pool must remain until the asynchronous event finishes and cleans everything up.
Diffstat (limited to 'nest/cli.c')
-rw-r--r--nest/cli.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/nest/cli.c b/nest/cli.c
index 469d45b6..1debfccf 100644
--- a/nest/cli.c
+++ b/nest/cli.c
@@ -307,14 +307,14 @@ cli_event(void *data)
}
cli *
-cli_new(void *priv)
+cli_new(struct birdsock *sock)
{
pool *p = rp_new(cli_pool, "CLI");
cli *c = mb_alloc(p, sizeof(cli));
bzero(c, sizeof(cli));
c->pool = p;
- c->priv = priv;
+ c->sock = sock;
c->event = ev_new(p);
c->event->hook = cli_event;
c->event->data = c;
@@ -415,7 +415,12 @@ cli_free(cli *c)
if (c == cmd_reconfig_stored_cli)
cmd_reconfig_stored_cli = NULL;
- if (!defer)
+ if (defer)
+ {
+ rfree(c->sock);
+ c->sock = NULL;
+ }
+ else
rfree(c->pool);
}