|
|
@ -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) |
|
|
|
static void parse_client_msg(conn_instance_t *ci, client_instance_t *client) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ckpool_t *ckp = ci->pi->ckp; |
|
|
|
ckpool_t *ckp = ci->pi->ckp; |
|
|
|
|
|
|
|
int buflen, ret, flags = 0; |
|
|
|
char msg[PAGESIZE], *eol; |
|
|
|
char msg[PAGESIZE], *eol; |
|
|
|
int buflen, ret, flags; |
|
|
|
|
|
|
|
bool moredata = false; |
|
|
|
|
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
|
|
|
|
|
|
|
|
retry: |
|
|
|
retry: |
|
|
|
buflen = PAGESIZE - client->bufofs; |
|
|
|
buflen = PAGESIZE - client->bufofs; |
|
|
|
if (moredata) |
|
|
|
|
|
|
|
flags = MSG_DONTWAIT; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
flags = 0; |
|
|
|
|
|
|
|
ret = recv(client->fd, client->buf + client->bufofs, buflen, flags); |
|
|
|
ret = recv(client->fd, client->buf + client->bufofs, buflen, flags); |
|
|
|
if (ret < 1) { |
|
|
|
if (ret < 1) { |
|
|
|
/* Nothing else ready to be read */ |
|
|
|
/* Nothing else ready to be read */ |
|
|
@ -212,10 +207,7 @@ retry: |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
client->bufofs += ret; |
|
|
|
client->bufofs += ret; |
|
|
|
if (client->bufofs == PAGESIZE) |
|
|
|
flags = MSG_DONTWAIT; |
|
|
|
moredata = true; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
moredata = false; |
|
|
|
|
|
|
|
reparse: |
|
|
|
reparse: |
|
|
|
eol = memchr(client->buf, '\n', client->bufofs); |
|
|
|
eol = memchr(client->buf, '\n', client->bufofs); |
|
|
|
if (!eol) { |
|
|
|
if (!eol) { |
|
|
@ -224,9 +216,7 @@ reparse: |
|
|
|
invalidate_client(ckp, ci, client); |
|
|
|
invalidate_client(ckp, ci, client); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (moredata) |
|
|
|
|
|
|
|
goto retry; |
|
|
|
goto retry; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Do something useful with this message now */ |
|
|
|
/* Do something useful with this message now */ |
|
|
@ -271,7 +261,6 @@ reparse: |
|
|
|
|
|
|
|
|
|
|
|
if (client->bufofs) |
|
|
|
if (client->bufofs) |
|
|
|
goto reparse; |
|
|
|
goto reparse; |
|
|
|
if (moredata) |
|
|
|
|
|
|
|
goto retry; |
|
|
|
goto retry; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|