summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-02-15 12:10:26 +0100
committerJeremy Allison <jra@samba.org>2013-03-01 12:00:11 -0800
commit2b05c9621784da8e5aa793cd2110dde768084968 (patch)
tree35675037738b0bf34b0bf9f3c347433d6c14626b /lib
parent8764ec80bbcba93e862c069766c00944e5187ed5 (diff)
downloadsamba-2b05c9621784da8e5aa793cd2110dde768084968.tar.gz
samba-2b05c9621784da8e5aa793cd2110dde768084968.tar.bz2
samba-2b05c9621784da8e5aa793cd2110dde768084968.zip
tevent: add epoll_{create,ctl}_panic_fallback() for testing
This makes sure we only do random panics if a fallback handler is registered. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/tevent/tevent_epoll.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index 99d4806db0..4c16aec5d6 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -44,11 +44,50 @@ struct epoll_event_context {
};
#ifdef TEST_PANIC_FALLBACK
-static int epoll_wait_panic_fallback(int epfd,
- struct epoll_event *events,
- int maxevents,
- int timeout)
+
+static int epoll_create_panic_fallback(struct epoll_event_context *epoll_ev,
+ int size)
+{
+ if (epoll_ev->panic_fallback == NULL) {
+ return epoll_create(size);
+ }
+
+ /* 50% of the time, fail... */
+ if ((random() % 2) == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return epoll_create(size);
+}
+
+static int epoll_ctl_panic_fallback(struct epoll_event_context *epoll_ev,
+ int epfd, int op, int fd,
+ struct epoll_event *event)
+{
+ if (epoll_ev->panic_fallback == NULL) {
+ return epoll_ctl(epfd, op, fd, event);
+ }
+
+ /* 50% of the time, fail... */
+ if ((random() % 2) == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return epoll_ctl(epfd, op, fd, event);
+}
+
+static int epoll_wait_panic_fallback(struct epoll_event_context *epoll_ev,
+ int epfd,
+ struct epoll_event *events,
+ int maxevents,
+ int timeout)
{
+ if (epoll_ev->panic_fallback == NULL) {
+ return epoll_wait(epfd, events, maxevents, timeout);
+ }
+
/* 50% of the time, fail... */
if ((random() % 2) == 0) {
errno = EINVAL;
@@ -58,7 +97,12 @@ static int epoll_wait_panic_fallback(int epfd,
return epoll_wait(epfd, events, maxevents, timeout);
}
-#define epoll_wait epoll_wait_panic_fallback
+#define epoll_create(_size) \
+ epoll_create_panic_fallback(epoll_ev, _size)
+#define epoll_ctl(_epfd, _op, _fd, _event) \
+ epoll_ctl_panic_fallback(epoll_ev,_epfd, _op, _fd, _event)
+#define epoll_wait(_epfd, _events, _maxevents, _timeout) \
+ epoll_wait_panic_fallback(epoll_ev, _epfd, _events, _maxevents, _timeout)
#endif
/*