mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-10-04 15:58:29 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user