From 8f1336986f91358786d4c4c9cfa88ec0058ab7ac Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 26 Apr 2015 18:06:20 +1000 Subject: [PATCH] Use a unique event structure for each client added to the epoll list --- src/connector.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/connector.c b/src/connector.c index 2c1fb215..2f0840f6 100644 --- a/src/connector.c +++ b/src/connector.c @@ -30,6 +30,7 @@ struct client_instance { UT_hash_handle hh; int64_t id; int fd; + struct epoll_event event; /* Reference count for when this instance is used outside of the * connector_data lock */ @@ -167,7 +168,6 @@ static int accept_client(cdata_t *cdata, const int epfd, const uint64_t server) int fd, port, no_clients, sockd; ckpool_t *ckp = cdata->ckp; client_instance_t *client; - struct epoll_event event; socklen_t address_len; ck_rlock(&cdata->lock); @@ -230,9 +230,9 @@ static int accept_client(cdata_t *cdata, const int epfd, const uint64_t server) ck_wunlock(&cdata->lock); client->fd = fd; - event.data.u64 = client->id; - event.events = EPOLLIN | EPOLLRDHUP; - if (unlikely(epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event) < 0)) { + client->event.data.u64 = client->id; + client->event.events = EPOLLIN | EPOLLRDHUP; + if (unlikely(epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &client->event) < 0)) { LOGERR("Failed to epoll_ctl add in accept_client"); return 0; } @@ -256,7 +256,7 @@ static int drop_client(cdata_t *cdata, client_instance_t *client) if (fd != -1) { client_id = client->id; - epoll_ctl(cdata->epfd, EPOLL_CTL_DEL, fd, NULL); + epoll_ctl(cdata->epfd, EPOLL_CTL_DEL, fd, &client->event); nolinger_socket(fd); Close(client->fd); HASH_DEL(cdata->clients, client);