From 2bde0bbe3d51a86e857bbc8e3f11393a0723d028 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 26 Apr 2015 17:38:36 +1000 Subject: [PATCH] Avoid trying to parse messages or test the client's error if their fd has already been invalidated --- src/connector.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/connector.c b/src/connector.c index b1a3742d..38052a23 100644 --- a/src/connector.c +++ b/src/connector.c @@ -506,10 +506,14 @@ void *receiver(void *arg) LOGNOTICE("Failed to find client by id %"PRId64" in receiver!", event.data.u64); continue; } + if (unlikely(client->fd == -1)) + goto noparse; /* We can have both messages and read hang ups so process the * message first. */ if (likely(event.events & EPOLLIN)) parse_client_msg(cdata, client); + if (unlikely(client->fd == -1)) + goto noparse; if (unlikely(event.events & EPOLLERR)) { socklen_t errlen = sizeof(int); int error = 0; @@ -534,6 +538,7 @@ void *receiver(void *arg) LOGINFO("Client id %"PRId64" fd %d RDHUP in epoll", client->id, client->fd); invalidate_client(cdata->pi->ckp, cdata, client); } +noparse: dec_instance_ref(cdata, client); } return NULL;