diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-09-27 20:00:00 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-09-29 11:08:04 -0400 |
commit | 70f1b2ddc6b94d3fa5539eb8503887b465f7fcc7 (patch) | |
tree | a5e80f2a72aabec123601d73576a38e2559a2cc0 | |
parent | 4bed248505da4da94d82078fe60326a374970e97 (diff) |
journal-remote: fix handling of non-blocking sources
In the conversion to sd-event loop, handling of normal files got
broken. We do not want to perform non-blocking reads on them, but
simply do read() in a loop. Install a statically-enabled "source"
to do that.
-rw-r--r-- | src/journal-remote/journal-remote.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index ad87783510..c97cfe613e 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -295,6 +295,8 @@ static int dispatch_raw_source_event(sd_event_source *event, int fd, uint32_t revents, void *userdata); +static int dispatch_blocking_source_event(sd_event_source *event, + void *userdata); static int dispatch_raw_connection_event(sd_event_source *event, int fd, uint32_t revents, @@ -378,6 +380,13 @@ static int add_source(RemoteServer *s, int fd, char* name, bool own_name) { r = sd_event_add_io(s->events, &source->event, fd, EPOLLIN|EPOLLRDHUP|EPOLLPRI, dispatch_raw_source_event, s); + if (r == -EPERM) { + log_debug("Falling back to sd_event_add_defer for fd:%d (%s)", fd, name); + r = sd_event_add_defer(s->events, &source->event, + dispatch_blocking_source_event, source); + if (r == 0) + sd_event_source_set_enabled(source->event, SD_EVENT_ON); + } if (r < 0) { log_error("Failed to register event source for fd:%d: %s", fd, strerror(-r)); @@ -1029,6 +1038,13 @@ static int dispatch_raw_source_event(sd_event_source *event, return 1; } +static int dispatch_blocking_source_event(sd_event_source *event, + void *userdata) { + RemoteSource *source = userdata; + + return dispatch_raw_source_event(event, source->fd, EPOLLIN, server); +} + static int accept_connection(const char* type, int fd, SocketAddress *addr, char **hostname) { int fd2, r; |