diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/journal/journald.c | 21 | ||||
-rw-r--r-- | src/log.c | 18 |
2 files changed, 9 insertions, 30 deletions
diff --git a/src/journal/journald.c b/src/journal/journald.c index f63a12fae8..73f8ed6ae8 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -66,8 +66,6 @@ #define RECHECK_VAR_AVAILABLE_USEC (30*USEC_PER_SEC) -#define SYSLOG_TIMEOUT_USEC (250*USEC_PER_MSEC) - #define N_IOVEC_META_FIELDS 17 #define ENTRY_SIZE_MAX (1024*1024*32) @@ -2220,7 +2218,6 @@ static int open_syslog_socket(Server *s) { union sockaddr_union sa; int one, r; struct epoll_event ev; - struct timeval tv; assert(s); @@ -2245,7 +2242,8 @@ static int open_syslog_socket(Server *s) { } chmod(sa.un.sun_path, 0666); - } + } else + fd_nonblock(s->syslog_fd, 1); one = 1; r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)); @@ -2261,15 +2259,6 @@ static int open_syslog_socket(Server *s) { return -errno; } - /* Since we use the same socket for forwarding this to some - * other syslog implementation, make sure we don't hang - * forever */ - timeval_store(&tv, SYSLOG_TIMEOUT_USEC); - if (setsockopt(s->syslog_fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0) { - log_error("SO_SNDTIMEO failed: %m"); - return -errno; - } - zero(ev); ev.events = EPOLLIN; ev.data.fd = s->syslog_fd; @@ -2309,7 +2298,8 @@ static int open_native_socket(Server*s) { } chmod(sa.un.sun_path, 0666); - } + } else + fd_nonblock(s->native_fd, 1); one = 1; r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)); @@ -2369,7 +2359,8 @@ static int open_stdout_socket(Server *s) { log_error("liste() failed: %m"); return -errno; } - } + } else + fd_nonblock(s->stdout_fd, 1); zero(ev); ev.events = EPOLLIN; @@ -33,8 +33,6 @@ #include "macro.h" #include "socket-util.h" -#define SOCKET_TIMEOUT_USEC (5*USEC_PER_SEC) - static LogTarget log_target = LOG_TARGET_CONSOLE; static int log_max_level = LOG_INFO; @@ -120,25 +118,15 @@ void log_close_syslog(void) { } static int create_log_socket(int type) { - struct timeval tv; int fd; - if (getpid() == 1) - /* systemd should not block on syslog */ - type |= SOCK_NONBLOCK; + /* All output to the syslog/journal fds we do asynchronously, + * and if the buffers are full we just drop the messages */ - fd = socket(AF_UNIX, type|SOCK_CLOEXEC, 0); + fd = socket(AF_UNIX, type|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); if (fd < 0) return -errno; - /* Make sure we don't block for more than 5s when talking to - * syslog */ - timeval_store(&tv, SOCKET_TIMEOUT_USEC); - if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0) { - close_nointr_nofail(fd); - return -errno; - } - return fd; } |