Browse Source

Add buf offset to disconnect message and reset flags on looping

master
Con Kolivas 10 years ago
parent
commit
2d6d982bb1
  1. 8
      src/connector.c

8
src/connector.c

@ -186,8 +186,8 @@ 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; bool moredata = false;
json_t *val; json_t *val;
@ -195,6 +195,8 @@ retry:
buflen = PAGESIZE - client->bufofs; buflen = PAGESIZE - client->bufofs;
if (moredata) if (moredata)
flags = MSG_DONTWAIT; 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 */
@ -204,8 +206,8 @@ retry:
/* 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. */
LOGINFO("Client fd %d disconnected with ret %d errno %d %s", client->fd, LOGINFO("Client fd %d disconnected with bufofs %d ret %d errno %d %s",
ret, errno, errno ? strerror(errno) : ""); client->fd, client->bufofs, ret, errno, errno ? strerror(errno) : "");
invalidate_client(ckp, ci, client); invalidate_client(ckp, ci, client);
return; return;
} }

Loading…
Cancel
Save