X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Flog.c;h=8f4995a0c8834f3cb5c4e95cc9071705994758da;hp=27317f7ed3ce13c4811d8ad53fa311f6e7b9e785;hb=8b18fdc19531ba56d0bdfe34c62870997a9bcc96;hpb=41f1a1da57a0cef035d1f78c21bcff3dc3f76f79 diff --git a/src/shared/log.c b/src/shared/log.c index 27317f7ed..8f4995a0c 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -115,16 +115,20 @@ void log_close_syslog(void) { static int create_log_socket(int type) { int fd; + struct timeval tv; - /* 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|SOCK_NONBLOCK, 0); + fd = socket(AF_UNIX, type|SOCK_CLOEXEC, 0); if (fd < 0) return -errno; fd_inc_sndbuf(fd, SNDBUF_SIZE); + /* We need a blocking fd here since we'd otherwise lose + messages way too early. However, let's not hang forever in the + unlikely case of a deadlock. */ + timeval_store(&tv, 1*USEC_PER_MINUTE); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); + return fd; }