summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2015-02-25 17:50:33 +0100
committerSimon Rettberg2015-02-25 17:50:33 +0100
commitdd1b647b0b8193a58c047daee6079417b07a5ac5 (patch)
treef943759257defe1f57bf1921b84a483e3be8494b
parentHack in support for numeric account names (diff)
downloadldadp-dd1b647b0b8193a58c047daee6079417b07a5ac5.tar.gz
ldadp-dd1b647b0b8193a58c047daee6079417b07a5ac5.tar.xz
ldadp-dd1b647b0b8193a58c047daee6079417b07a5ac5.zip
Fix epoll based detection of closed connections
-rw-r--r--client.c9
-rw-r--r--epoll.c3
-rw-r--r--ldadp.c2
3 files changed, 9 insertions, 5 deletions
diff --git a/client.c b/client.c
index e9e9453..f2c9683 100644
--- a/client.c
+++ b/client.c
@@ -31,7 +31,7 @@ void client_callback(void *data, int haveIn, int haveOut, int doCleanup)
{
epoll_client_t *client = (epoll_client_t*)data;
if (doCleanup || client->kill) {
- printf("Client gone.\n");
+ printf("Client gone (1).\n");
client_free(client);
return;
}
@@ -39,7 +39,10 @@ void client_callback(void *data, int haveIn, int haveOut, int doCleanup)
// Plain connection
if (haveIn) client_haveIn(client);
if (haveOut) client_haveOut(client);
- if (client->kill) client_free(client);
+ if (client->kill) {
+ printf("Client gone (2).\n");
+ client_free(client);
+ }
return;
}
// SSL connection
@@ -56,7 +59,7 @@ void client_callback(void *data, int haveIn, int haveOut, int doCleanup)
client_haveIn(client);
client_haveOut(client);
if (client->kill) {
- printf("Client killed.\n");
+ printf("Client gone (3).\n");
client_free(client);
}
}
diff --git a/epoll.c b/epoll.c
index 576fb0e..6da0d40 100644
--- a/epoll.c
+++ b/epoll.c
@@ -20,7 +20,7 @@ int ePoll_wait(const int timeoutMs)
if (num < 0) return -1;
for (int i = 0; i < num; ++i) {
epoll_item_t *data = (epoll_item_t *)events[i].data.ptr;
- (*data->callback)(data, events[i].events & EPOLLIN, events[i].events & EPOLLOUT, events[i].events & (EPOLLERR | EPOLLHUP));
+ (*data->callback)(data, events[i].events & EPOLLIN, events[i].events & EPOLLOUT, events[i].events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP));
}
return 0;
}
@@ -31,6 +31,7 @@ int ePoll_wait(const int timeoutMs)
int ePoll_add(uint32_t flags, epoll_item_t* callback)
{
struct epoll_event event;
+ memset(&event, 0, sizeof event);
event.data.ptr = (void*)callback;
event.events = flags;
return epoll_ctl(efd, EPOLL_CTL_ADD, callback->fd, &event);
diff --git a/ldadp.c b/ldadp.c
index b0e8e52..584da8a 100644
--- a/ldadp.c
+++ b/ldadp.c
@@ -101,7 +101,7 @@ static void listen_callback(void *data, int haveIn, int haveOut, int doCleanup)
free(client);
return;
}
- ePoll_add(EPOLLIN | EPOLLOUT | EPOLLET, (epoll_item_t*)client);
+ ePoll_add(EPOLLIN | EPOLLOUT | EPOLLET | EPOLLRDHUP, (epoll_item_t*)client);
}
static int loadConfig_handler(void *stuff, const char *section, const char *key, const char *value)