summaryrefslogtreecommitdiff
path: root/lib/tevent/tevent.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-09-07 19:17:21 +0200
committerJeremy Allison <jra@samba.org>2016-10-05 00:06:21 +0200
commitd90f325878f8aab5c66ac304e501627040788138 (patch)
tree3b5345a808b5d7b013fe8a282e2e82b56086ef08 /lib/tevent/tevent.c
parent0ecefd5bf91ae8297569dc862d7259e942d895fe (diff)
downloadsamba-d90f325878f8aab5c66ac304e501627040788138.tar.gz
tevent: Rename wakeup fds
This makes the reading end of the signalling pipe special: If we have eventfd, this is the same as the write fd. Without eventfd, it will have to be a separate fd. This moves the requirement to #ifdef from the writing end to the reading end. Why? We'll use the writing end somewhere else too soon, and this patch avoids an #ifdef in that new place. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tevent/tevent.c')
-rw-r--r--lib/tevent/tevent.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index 331be0eb110..87776ec1bb4 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -860,7 +860,7 @@ static void wakeup_pipe_handler(struct tevent_context *ev,
int tevent_common_wakeup_init(struct tevent_context *ev)
{
- int ret;
+ int ret, read_fd;
if (ev->wakeup_fde != NULL) {
return 0;
@@ -871,7 +871,7 @@ int tevent_common_wakeup_init(struct tevent_context *ev)
if (ret == -1) {
return errno;
}
- ev->wakeup_fd = ret;
+ read_fd = ev->wakeup_fd = ret;
#else
{
int pipe_fds[2];
@@ -879,21 +879,22 @@ int tevent_common_wakeup_init(struct tevent_context *ev)
if (ret == -1) {
return errno;
}
- ev->wakeup_fd = pipe_fds[0];
- ev->wakeup_write_fd = pipe_fds[1];
+ ev->wakeup_fd = pipe_fds[1];
+ ev->wakeup_read_fd = pipe_fds[0];
ev_set_blocking(ev->wakeup_fd, false);
- ev_set_blocking(ev->wakeup_write_fd, false);
+ ev_set_blocking(ev->wakeup_read_fd, false);
+
+ read_fd = ev->wakeup_read_fd;
}
#endif
- ev->wakeup_fde = tevent_add_fd(ev, ev, ev->wakeup_fd,
- TEVENT_FD_READ,
+ ev->wakeup_fde = tevent_add_fd(ev, ev, read_fd, TEVENT_FD_READ,
wakeup_pipe_handler, NULL);
if (ev->wakeup_fde == NULL) {
close(ev->wakeup_fd);
#ifndef HAVE_EVENTFD
- close(ev->wakeup_write_fd);
+ close(ev->wakeup_read_fd);
#endif
return ENOMEM;
}
@@ -915,7 +916,7 @@ int tevent_common_wakeup(struct tevent_context *ev)
ret = write(ev->wakeup_fd, &val, sizeof(val));
#else
char c = '\0';
- ret = write(ev->wakeup_write_fd, &c, 1);
+ ret = write(ev->wakeup_fd, &c, 1);
#endif
} while ((ret == -1) && (errno == EINTR));
@@ -932,6 +933,6 @@ static void tevent_common_wakeup_fini(struct tevent_context *ev)
close(ev->wakeup_fd);
#ifndef HAVE_EVENTFD
- close(ev->wakeup_write_fd);
+ close(ev->wakeup_read_fd);
#endif
}