summaryrefslogtreecommitdiff
path: root/sysdep/unix/main.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 /sysdep/unix/main.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 'sysdep/unix/main.c')
-rw-r--r--sysdep/unix/main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index bf9f2be0..74827d98 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -395,7 +395,8 @@ static char *path_control_socket = PATH_CONTROL_SOCKET;
static void
cli_write(cli *c)
{
- sock *s = c->priv;
+ sock *s = c->sock;
+ ASSERT_DIE(c->sock);
while (c->tx_pos)
{
@@ -419,7 +420,9 @@ cli_write(cli *c)
void
cli_write_trigger(cli *c)
{
- sock *s = c->priv;
+ sock *s = c->sock;
+ if (!s)
+ return;
if (s->tbuf == NULL)
cli_write(c);
@@ -434,7 +437,8 @@ cli_tx(sock *s)
int
cli_get_command(cli *c)
{
- sock *s = c->priv;
+ sock *s = c->sock;
+ ASSERT_DIE(c->sock);
byte *t = c->rx_aux ? : s->rbuf;
byte *tend = s->rpos;
byte *d = c->rx_pos;
@@ -477,6 +481,7 @@ cli_err(sock *s, int err)
else
log(L_INFO "CLI connection closed");
}
+
cli_free(s->data);
}