#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)
union sockaddr_union sa;
int one, r;
struct epoll_event ev;
- struct timeval tv;
assert(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));
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;
}
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));
log_error("liste() failed: %m");
return -errno;
}
- }
+ } else
+ fd_nonblock(s->stdout_fd, 1);
zero(ev);
ev.events = EPOLLIN;
#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;
}
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;
}