summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-08-17 05:21:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:02:02 -0500
commit1133678c346d51f669892973a4c99982c7b28f86 (patch)
treeee07c4764ec6007a85e7134ddf7ed4dbf817d9d1 /source4
parent113587b823fba2f48b22da03e036771f6ecf6611 (diff)
downloadsamba-1133678c346d51f669892973a4c99982c7b28f86.tar.gz
samba-1133678c346d51f669892973a4c99982c7b28f86.tar.bz2
samba-1133678c346d51f669892973a4c99982c7b28f86.zip
r24502: More work to get LOCAL-EVENT passing on all platforms:
- Make the epoll_event_context_init() call fail if epoll_create() fails. This should cause this backend to be skipped on host with epoll() in libc but not in the kernel. - At the moment, there is no sensible way to handle failures to add an epoll() event, and 'fallback to select' is misnamed (so we now abort()). Andrew Bartlett (This used to be commit fb1e1eebdae740a2b66ee1ea9e1e35f21292ac14)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/events/events_epoll.c29
-rw-r--r--source4/torture/local/event.c9
2 files changed, 19 insertions, 19 deletions
diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c
index 5e1c1417c8..acd204c898 100644
--- a/source4/lib/events/events_epoll.c
+++ b/source4/lib/events/events_epoll.c
@@ -56,12 +56,10 @@ struct epoll_event_context {
called when a epoll call fails, and we should fallback
to using select
*/
-static void epoll_fallback_to_select(struct epoll_event_context *epoll_ev, const char *reason)
+static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
{
- DEBUG(0,("%s (%s) - falling back to select()\n", reason, strerror(errno)));
- close(epoll_ev->epoll_fd);
- epoll_ev->epoll_fd = -1;
- talloc_set_destructor(epoll_ev, NULL);
+ DEBUG(0,("%s (%s) - calling abort()\n", reason, strerror(errno)));
+ abort();
}
/*
@@ -88,11 +86,15 @@ static int epoll_ctx_destructor(struct epoll_event_context *epoll_ev)
/*
init the epoll fd
*/
-static void epoll_init_ctx(struct epoll_event_context *epoll_ev)
+static int epoll_init_ctx(struct epoll_event_context *epoll_ev)
{
epoll_ev->epoll_fd = epoll_create(64);
epoll_ev->pid = getpid();
talloc_set_destructor(epoll_ev, epoll_ctx_destructor);
+ if (epoll_ev->epoll_fd == -1) {
+ return -1;
+ }
+ return 0;
}
static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_event *fde);
@@ -144,7 +146,7 @@ static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_even
event.events = epoll_map_flags(fde->flags);
event.data.ptr = fde;
if (epoll_ctl(epoll_ev->epoll_fd, EPOLL_CTL_ADD, fde->fd, &event) != 0) {
- epoll_fallback_to_select(epoll_ev, "EPOLL_CTL_ADD failed");
+ epoll_panic(epoll_ev, "EPOLL_CTL_ADD failed");
}
fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT;
@@ -193,7 +195,7 @@ static void epoll_mod_event(struct epoll_event_context *epoll_ev, struct fd_even
event.events = epoll_map_flags(fde->flags);
event.data.ptr = fde;
if (epoll_ctl(epoll_ev->epoll_fd, EPOLL_CTL_MOD, fde->fd, &event) != 0) {
- epoll_fallback_to_select(epoll_ev, "EPOLL_CTL_MOD failed");
+ epoll_panic(epoll_ev, "EPOLL_CTL_MOD failed");
}
/* only if we want to read we want to tell the event handler about errors */
@@ -268,7 +270,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
}
if (ret == -1 && errno != EINTR) {
- epoll_fallback_to_select(epoll_ev, "epoll_wait() failed");
+ epoll_panic(epoll_ev, "epoll_wait() failed");
return -1;
}
@@ -284,7 +286,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
uint16_t flags = 0;
if (fde == NULL) {
- epoll_fallback_to_select(epoll_ev, "epoll_wait() gave bad data");
+ epoll_panic(epoll_ev, "epoll_wait() gave bad data");
return -1;
}
if (events[i].events & (EPOLLHUP|EPOLLERR)) {
@@ -319,6 +321,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
*/
static int epoll_event_context_init(struct event_context *ev)
{
+ int ret;
struct epoll_event_context *epoll_ev;
epoll_ev = talloc_zero(ev, struct epoll_event_context);
@@ -326,7 +329,11 @@ static int epoll_event_context_init(struct event_context *ev)
epoll_ev->ev = ev;
epoll_ev->epoll_fd = -1;
- epoll_init_ctx(epoll_ev);
+ ret = epoll_init_ctx(epoll_ev);
+ if (ret != 0) {
+ talloc_free(epoll_ev);
+ return ret;
+ }
ev->additional_data = epoll_ev;
return 0;
diff --git a/source4/torture/local/event.c b/source4/torture/local/event.c
index d3ef9d5090..e2c7de1c72 100644
--- a/source4/torture/local/event.c
+++ b/source4/torture/local/event.c
@@ -100,14 +100,7 @@ static bool test_event_context(struct torture_context *test,
errno = 0;
if (event_loop_once(ev_ctx) == -1) {
talloc_free(ev_ctx);
- if (errno == ENOSYS) {
- torture_comment(test, "Host kernel does not support %s event backend!", backend);
- talloc_free(ev_ctx);
-
- return true;
- } else {
- torture_fail(test, talloc_asprintf(test, "Failed event loop %s\n", strerror(errno)));
- }
+ torture_fail(test, talloc_asprintf(test, "Failed event loop %s\n", strerror(errno)));
}
}