summaryrefslogtreecommitdiff
path: root/lib/tevent
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-09-07 19:47:55 +0200
committerJeremy Allison <jra@samba.org>2016-10-05 00:06:21 +0200
commit5b3019cb91f732f95f65c228a2483788f54faa8b (patch)
tree2d318bd19f7dbc9f0b954ad7f295ff734f5d89e8 /lib/tevent
parentd90f325878f8aab5c66ac304e501627040788138 (diff)
downloadsamba-5b3019cb91f732f95f65c228a2483788f54faa8b.tar.gz
tevent: Add tevent_common_wakeup_fd()
This prepares tevent run-down with active threads. It has the advantage to not depend on talloc'ed structs. It is needed to make talloc_free(tevent_context) safe when tevent_threaded_contexts are still around. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tevent')
-rw-r--r--lib/tevent/ABI/tevent-0.9.30.sigs1
-rw-r--r--lib/tevent/tevent.c19
-rw-r--r--lib/tevent/tevent_internal.h1
3 files changed, 14 insertions, 7 deletions
diff --git a/lib/tevent/ABI/tevent-0.9.30.sigs b/lib/tevent/ABI/tevent-0.9.30.sigs
index 66a450e1545..ea179a0d63f 100644
--- a/lib/tevent/ABI/tevent-0.9.30.sigs
+++ b/lib/tevent/ABI/tevent-0.9.30.sigs
@@ -36,6 +36,7 @@ tevent_common_loop_wait: int (struct tevent_context *, const char *)
tevent_common_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
tevent_common_threaded_activate_immediate: void (struct tevent_context *)
tevent_common_wakeup: int (struct tevent_context *)
+tevent_common_wakeup_fd: int (int)
tevent_common_wakeup_init: int (struct tevent_context *)
tevent_context_init: struct tevent_context *(TALLOC_CTX *)
tevent_context_init_byname: struct tevent_context *(TALLOC_CTX *, const char *)
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index 87776ec1bb4..575337d4109 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -902,27 +902,32 @@ int tevent_common_wakeup_init(struct tevent_context *ev)
return 0;
}
-int tevent_common_wakeup(struct tevent_context *ev)
+int tevent_common_wakeup_fd(int fd)
{
ssize_t ret;
- if (ev->wakeup_fde == NULL) {
- return ENOTCONN;
- }
-
do {
#ifdef HAVE_EVENTFD
uint64_t val = 1;
- ret = write(ev->wakeup_fd, &val, sizeof(val));
+ ret = write(fd, &val, sizeof(val));
#else
char c = '\0';
- ret = write(ev->wakeup_fd, &c, 1);
+ ret = write(fd, &c, 1);
#endif
} while ((ret == -1) && (errno == EINTR));
return 0;
}
+int tevent_common_wakeup(struct tevent_context *ev)
+{
+ if (ev->wakeup_fde == NULL) {
+ return ENOTCONN;
+ }
+
+ return tevent_common_wakeup_fd(ev->wakeup_fd);
+}
+
static void tevent_common_wakeup_fini(struct tevent_context *ev)
{
if (ev->wakeup_fde == NULL) {
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index 84ae5bcfc85..a4af79e85ac 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -357,6 +357,7 @@ void tevent_common_threaded_activate_immediate(struct tevent_context *ev);
bool tevent_common_have_events(struct tevent_context *ev);
int tevent_common_wakeup_init(struct tevent_context *ev);
+int tevent_common_wakeup_fd(int fd);
int tevent_common_wakeup(struct tevent_context *ev);
struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,