From: Zbigniew Jędrzejewski-Szmek Date: Sun, 28 Sep 2014 00:00:00 +0000 (-0400) Subject: journal-remote: fix handling of non-blocking sources X-Git-Tag: v217~406 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70f1b2ddc6b94d3fa5539eb8503887b465f7fcc7;p=platform%2Fupstream%2Fsystemd.git 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. --- 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;