From e3b4d969d5d4092bb30d852ccaa1427403c0e26b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 3 Oct 2014 10:31:52 +1000 Subject: [PATCH] Always re-read with dontwait when parsing a client message --- src/connector.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/connector.c b/src/connector.c index 4090a567..9439ec0d 100644 --- a/src/connector.c +++ b/src/connector.c @@ -186,17 +186,12 @@ static void send_client(conn_instance_t *ci, int64_t id, char *buf); static void parse_client_msg(conn_instance_t *ci, client_instance_t *client) { ckpool_t *ckp = ci->pi->ckp; + int buflen, ret, flags = 0; char msg[PAGESIZE], *eol; - int buflen, ret, flags; - bool moredata = false; json_t *val; retry: buflen = PAGESIZE - client->bufofs; - if (moredata) - flags = MSG_DONTWAIT; - else - flags = 0; ret = recv(client->fd, client->buf + client->bufofs, buflen, flags); if (ret < 1) { /* Nothing else ready to be read */ @@ -212,10 +207,7 @@ retry: return; } client->bufofs += ret; - if (client->bufofs == PAGESIZE) - moredata = true; - else - moredata = false; + flags = MSG_DONTWAIT; reparse: eol = memchr(client->buf, '\n', client->bufofs); if (!eol) { @@ -224,9 +216,7 @@ reparse: invalidate_client(ckp, ci, client); return; } - if (moredata) - goto retry; - return; + goto retry; } /* Do something useful with this message now */ @@ -271,8 +261,7 @@ reparse: if (client->bufofs) goto reparse; - if (moredata) - goto retry; + goto retry; } /* Waits on fds ready to read on from the list stored in conn_instance and