diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2009-07-14 14:18:54 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2009-07-14 14:18:54 +0200 |
commit | 6baef17ecf1ed994cfc8038bc610e8b7ff88506a (patch) | |
tree | 60f9b74e148cf87cd014ffd6c3f885f7d6c2b185 /sysdep/unix/main.c | |
parent | 70670bf317a612a1700ffbd0dbc8d92614e0caf2 (diff) |
Fixes bug in CLI TX buffer management.
Diffstat (limited to 'sysdep/unix/main.c')
-rw-r--r-- | sysdep/unix/main.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 5f5b165f..17845d20 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -178,22 +178,44 @@ cmd_reconfig(char *name, int type) static sock *cli_sk; static char *path_control_socket = PATH_CONTROL_SOCKET; -int + +static void cli_write(cli *c) { sock *s = c->priv; - if (c->tx_pos) + while (c->tx_pos) { struct cli_out *o = c->tx_pos; + + int len = o->wpos - o->outpos; s->tbuf = o->outpos; - if (sk_send(s, o->wpos - o->outpos) > 0) - { - c->tx_pos = o->next; - ev_schedule(c->event); - } + o->outpos = o->wpos; + + if (sk_send(s, len) <= 0) + return; + + c->tx_pos = o->next; } - return !c->tx_pos; + + /* Everything is written */ + s->tbuf = NULL; + cli_written(c); +} + +void +cli_write_trigger(cli *c) +{ + sock *s = c->priv; + + if (s->tbuf == NULL) + cli_write(c); +} + +static void +cli_tx(sock *s) +{ + cli_write(s->data); } int @@ -233,15 +255,6 @@ cli_rx(sock *s, int size UNUSED) } static void -cli_tx(sock *s) -{ - cli *c = s->data; - - if (cli_write(c)) - cli_written(c); -} - -static void cli_err(sock *s, int err) { if (config->cli_debug) |