Browse Source

Process epoll read messages before hangups and errors and add more info about the type of hang up, increasing verbosity when it's an unexpected error

master
Con Kolivas 10 years ago
parent
commit
8bb50fa058
  1. 32
      src/connector.c

32
src/connector.c

@ -494,12 +494,34 @@ void *receiver(void *arg)
LOGWARNING("Failed to find client by id in receiver!"); LOGWARNING("Failed to find client by id in receiver!");
continue; continue;
} }
if (event.events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) { /* We can have both messages and read hang ups so process the
/* Client disconnected */ * message first. */
LOGDEBUG("Client fd %d HUP in epoll", client->fd); if (likely(event.events & EPOLLIN))
invalidate_client(cdata->pi->ckp, cdata, client);
} else
parse_client_msg(cdata, client); parse_client_msg(cdata, client);
if (unlikely(event.events & EPOLLERR)) {
socklen_t errlen = sizeof(int);
int error = 0;
/* See what type of error this is and raise the log
* level of the message if it's unexpected. */
getsockopt(client->fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen);
if (error != 104) {
LOGNOTICE("Client id %"PRId64" fd %d epollerr HUP in epoll with error %d: %s",
client->id, client->fd, error, strerror(error));
} else {
LOGINFO("Client id %"PRId64" fd %d epollerr HUP in epoll with error %d: %s",
client->id, client->fd, error, strerror(error));
}
invalidate_client(cdata->pi->ckp, cdata, client);
} else if (unlikely(event.events & EPOLLHUP)) {
/* Client connection reset by peer */
LOGINFO("Client id %"PRId64" fd %d HUP in epoll", client->id, client->fd);
invalidate_client(cdata->pi->ckp, cdata, client);
} else if (unlikely(event.events & EPOLLRDHUP)) {
/* Client disconnected by peer */
LOGINFO("Client id %"PRId64" fd %d RDHUP in epoll", client->id, client->fd);
invalidate_client(cdata->pi->ckp, cdata, client);
}
dec_instance_ref(cdata, client); dec_instance_ref(cdata, client);
} }
return NULL; return NULL;

Loading…
Cancel
Save