summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-02-11 10:52:30 -0800
committerJeremy Allison <jra@samba.org>2013-02-14 10:19:38 -0800
commit06fb88b449806d6de7ca20c73778dd6545a38cf7 (patch)
tree9a0fc29b339c2bee4d2b4ef9344f9fb535318e79 /lib
parent6f9819229b3d60cb898a0f9bfc67793b6c40fc2c (diff)
downloadsamba-06fb88b449806d6de7ca20c73778dd6545a38cf7.tar.gz
samba-06fb88b449806d6de7ca20c73778dd6545a38cf7.tar.bz2
samba-06fb88b449806d6de7ca20c73778dd6545a38cf7.zip
tevent: Add in some test code to allow the panic fallback path to be tested.
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.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index 0ef1ffe909..5a17331da6 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -43,6 +43,24 @@ struct epoll_event_context {
bool (*panic_fallback)(struct tevent_context *ev, bool replay);
};
+#ifdef TEST_PANIC_FALLBACK
+static int epoll_wait_panic_fallback(int epfd,
+ struct epoll_event *events,
+ int maxevents,
+ int timeout)
+{
+ /* 50% of the time, fail... */
+ if ((random() % 2) == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return epoll_wait(epfd, events, maxevents, timeout);
+}
+
+#define epoll_wait epoll_wait_panic_fallback
+#endif
+
/*
called to set the panic fallback function.
*/