summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-02-11 10:43:39 -0800
committerJeremy Allison <jra@samba.org>2013-02-14 10:19:38 -0800
commit04ba47e491d84f58562b57f937be632e75c204aa (patch)
tree65720160f4c9fa6d85fed526bd5566a100c71743 /lib
parente4ef2ecf023c63ee28e40a1b60ecc6091a126001 (diff)
downloadsamba-04ba47e491d84f58562b57f937be632e75c204aa.tar.gz
samba-04ba47e491d84f58562b57f937be632e75c204aa.tar.bz2
samba-04ba47e491d84f58562b57f937be632e75c204aa.zip
tevent: Add an internal function tevent_epoll_set_panic_fallback().
Can be set externally, allows us to fallback if epoll fails at runtime. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/tevent/tevent_epoll.c24
-rw-r--r--lib/tevent/tevent_internal.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index c7936d3c94..8a48d1d33d 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -39,9 +39,33 @@ struct epoll_event_context {
int epoll_fd;
pid_t pid;
+
+ bool (*panic_fallback)(struct tevent_context *ev, bool replay);
};
/*
+ called to set the panic fallback function.
+*/
+_PRIVATE_ bool tevent_epoll_set_panic_fallback(struct tevent_context *ev,
+ bool (*panic_fallback)(struct tevent_context *ev,
+ bool replay))
+{
+ struct epoll_event_context *epoll_ev;
+
+ if (ev->additional_data == NULL) {
+ return false;
+ }
+
+ epoll_ev = talloc_get_type(ev->additional_data,
+ struct epoll_event_context);
+ if (epoll_ev == NULL) {
+ return false;
+ }
+ epoll_ev->panic_fallback = panic_fallback;
+ return true;
+}
+
+/*
called when a epoll call fails
*/
static void epoll_panic(struct epoll_event_context *epoll_ev,
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index f09cf576b2..4e9cd69213 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -318,6 +318,9 @@ bool tevent_poll_init(void);
bool tevent_poll_mt_init(void);
#ifdef HAVE_EPOLL
bool tevent_epoll_init(void);
+bool tevent_epoll_set_panic_fallback(struct tevent_context *ev,
+ bool (*panic_fallback)(struct tevent_context *ev,
+ bool replay));
#endif
void tevent_trace_point_callback(struct tevent_context *ev,