Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-31 19:43:00 +0400
committerFelix Fietkau <nbd@openwrt.org>2013-01-31 19:43:08 +0400
commit766ff9805074f88846fdc7c8b78b6ae364665356 (patch)
treed76f07b454d635f3d94be7a90c318ec1d606473e /uloop.c
parentf24b6294c2d070e03ce663a60cdc50c9e5ab50e8 (diff)
uloop: remove file descriptors if neither read nor write notification is requested
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uloop.c')
-rw-r--r--uloop.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/uloop.c b/uloop.c
index a3ba3ad..f0ccb0c 100644
--- a/uloop.c
+++ b/uloop.c
@@ -246,6 +246,9 @@ int uloop_fd_delete(struct uloop_fd *sock)
{
int i;
+ if (!sock->registered)
+ return 0;
+
for (i = cur_fd + 1; i < cur_nfds; i++) {
if (events[i].data.ptr != sock)
continue;
@@ -302,6 +305,9 @@ int uloop_fd_add(struct uloop_fd *sock, unsigned int flags)
unsigned int fl;
int ret;
+ if (!(flags & (ULOOP_READ | ULOOP_WRITE)))
+ return uloop_fd_delete(sock);
+
if (!sock->registered && !(flags & ULOOP_BLOCKING)) {
fl = fcntl(sock->fd, F_GETFL, 0);
fl |= O_NONBLOCK;