0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

Fixed a couple of nasty CLI bugs which were triggered on long or multi-part

outputs. It took a whole evening to hunt them down, but now the CLI seems
to work fine.

Now I run three BGP connections with several thousand routes!
This commit is contained in:
Martin Mares 2000-04-27 22:35:08 +00:00
parent 54896cbdba
commit f75e3bbc01
3 changed files with 9 additions and 9 deletions

View File

@ -29,13 +29,13 @@ cli_alloc_out(cli *c, int size)
c->tx_write->next = o; c->tx_write->next = o;
else else
c->tx_buf = o; c->tx_buf = o;
o->next = NULL;
o->wpos = o->outpos = o->buf; o->wpos = o->outpos = o->buf;
o->end = o->buf + CLI_TX_BUF_SIZE; o->end = o->buf + CLI_TX_BUF_SIZE;
} }
c->tx_write = o; c->tx_write = o;
if (!c->tx_pos) if (!c->tx_pos)
c->tx_pos = o; c->tx_pos = o;
o->next = NULL;
} }
o->wpos += size; o->wpos += size;
return o->wpos - size; return o->wpos - size;
@ -123,7 +123,6 @@ cli_free_out(cli *c)
if (o = c->tx_buf) if (o = c->tx_buf)
{ {
c->tx_write = c->tx_pos = NULL;
o->wpos = o->outpos = o->buf; o->wpos = o->outpos = o->buf;
while (p = o->next) while (p = o->next)
{ {
@ -131,6 +130,7 @@ cli_free_out(cli *c)
mb_free(p); mb_free(p);
} }
} }
c->tx_write = c->tx_pos = NULL;
c->async_msg_size = 0; c->async_msg_size = 0;
} }
@ -175,7 +175,7 @@ cli_command(struct cli *c)
cli_printf(c, 9001, f.err_msg); cli_printf(c, 9001, f.err_msg);
} }
static int static void
cli_event(void *data) cli_event(void *data)
{ {
cli *c = data; cli *c = data;
@ -193,7 +193,7 @@ cli_event(void *data)
{ {
err = cli_get_command(c); err = cli_get_command(c);
if (!err) if (!err)
return 0; return;
if (err < 0) if (err < 0)
cli_printf(c, 9000, "Command too long"); cli_printf(c, 9000, "Command too long");
else else
@ -202,9 +202,8 @@ cli_event(void *data)
if (cli_write(c)) if (cli_write(c))
{ {
cli_free_out(c); cli_free_out(c);
return 1; ev_schedule(c->event);
} }
return 0;
} }
cli * cli *

View File

@ -870,7 +870,7 @@ sk_write(sock *s)
case SK_DELETED: case SK_DELETED:
return; return;
default: default:
while (s->ttx != s->tbuf && sk_maybe_write(s) > 0) while (s->ttx != s->tpos && sk_maybe_write(s) > 0)
s->tx_hook(s); s->tx_hook(s);
} }
} }

View File

@ -179,9 +179,10 @@ cli_write(cli *c)
struct cli_out *o = c->tx_pos; struct cli_out *o = c->tx_pos;
c->tx_pos = o->next; c->tx_pos = o->next;
s->tbuf = o->outpos; s->tbuf = o->outpos;
return sk_send(s, o->wpos - o->outpos); if (sk_send(s, o->wpos - o->outpos) > 0)
ev_schedule(c->event);
} }
return 1; return !c->tx_pos;
} }
int int