summaryrefslogtreecommitdiff
path: root/sysdep/unix/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdep/unix/main.c')
-rw-r--r--sysdep/unix/main.c47
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)