|
|
@ -187,22 +187,12 @@ 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; |
|
|
|
char msg[PAGESIZE], *eol; |
|
|
|
char msg[PAGESIZE], *eol; |
|
|
|
int buflen, ret, flags; |
|
|
|
int buflen, ret; |
|
|
|
bool moredata = false; |
|
|
|
|
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
|
|
|
|
|
|
|
|
retry: |
|
|
|
|
|
|
|
buflen = PAGESIZE - client->bufofs; |
|
|
|
buflen = PAGESIZE - client->bufofs; |
|
|
|
if (moredata) |
|
|
|
ret = recv(client->fd, client->buf + client->bufofs, buflen, 0); |
|
|
|
flags = MSG_DONTWAIT; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
flags = 0; |
|
|
|
|
|
|
|
ret = recv(client->fd, client->buf + client->bufofs, buflen, flags); |
|
|
|
|
|
|
|
if (ret < 1) { |
|
|
|
if (ret < 1) { |
|
|
|
/* Nothing else ready to be read */ |
|
|
|
|
|
|
|
if (!ret && flags) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* We should have something to read if called since poll set
|
|
|
|
/* We should have something to read if called since poll set
|
|
|
|
* this fd's revents status so if there's nothing it means the |
|
|
|
* this fd's revents status so if there's nothing it means the |
|
|
|
* client has disconnected. */ |
|
|
|
* client has disconnected. */ |
|
|
@ -212,10 +202,6 @@ retry: |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
client->bufofs += ret; |
|
|
|
client->bufofs += ret; |
|
|
|
if (client->bufofs == PAGESIZE) |
|
|
|
|
|
|
|
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,8 +210,6 @@ reparse: |
|
|
|
invalidate_client(ckp, ci, client); |
|
|
|
invalidate_client(ckp, ci, client); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (moredata) |
|
|
|
|
|
|
|
goto retry; |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -271,8 +255,6 @@ reparse: |
|
|
|
|
|
|
|
|
|
|
|
if (client->bufofs) |
|
|
|
if (client->bufofs) |
|
|
|
goto reparse; |
|
|
|
goto reparse; |
|
|
|
if (moredata) |
|
|
|
|
|
|
|
goto retry; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Waits on fds ready to read on from the list stored in conn_instance and
|
|
|
|
/* Waits on fds ready to read on from the list stored in conn_instance and
|
|
|
|