chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
get rid of unicode arrows, since the linux console cannot show them, not even in...
[elogind.git]
/
logger.c
diff --git
a/logger.c
b/logger.c
index af3293bd7e1812f6b46464e736bd5a8f5deb6b11..ba325c696c80c71ceeb9feeb36987e844a0a83c1 100644
(file)
--- a/
logger.c
+++ b/
logger.c
@@
-62,11
+62,6
@@
typedef enum StreamState {
STREAM_RUNNING
} StreamState;
STREAM_RUNNING
} StreamState;
-typedef enum LogTarget {
- LOG_TARGET_SYSLOG,
- LOG_TARGET_KMSG
-} LogTarget;
-
struct Stream {
Server *server;
struct Stream {
Server *server;
@@
-86,16
+81,9
@@
struct Stream {
LIST_FIELDS(Stream, stream);
};
LIST_FIELDS(Stream, stream);
};
-#define IOVEC_SET_STRING(iovec, s) \
- do { \
- (iovec).iov_base = s; \
- (iovec).iov_len = strlen(s); \
- } while(false);
-
static int stream_log(Stream *s, char *p, usec_t timestamp) {
char header_priority[16], header_time[64], header_pid[16];
static int stream_log(Stream *s, char *p, usec_t timestamp) {
char header_priority[16], header_time[64], header_pid[16];
- struct msghdr msghdr;
struct iovec iovec[5];
assert(s);
struct iovec iovec[5];
assert(s);
@@
-139,6
+127,8
@@
static int stream_log(Stream *s, char *p, usec_t timestamp) {
IOVEC_SET_STRING(iovec[0], header_priority);
if (s->target == LOG_TARGET_SYSLOG) {
IOVEC_SET_STRING(iovec[0], header_priority);
if (s->target == LOG_TARGET_SYSLOG) {
+ struct msghdr msghdr;
+
IOVEC_SET_STRING(iovec[1], header_time);
IOVEC_SET_STRING(iovec[2], s->process);
IOVEC_SET_STRING(iovec[3], header_pid);
IOVEC_SET_STRING(iovec[1], header_time);
IOVEC_SET_STRING(iovec[2], s->process);
IOVEC_SET_STRING(iovec[3], header_pid);
@@
-293,7
+283,7
@@
static void stream_free(Stream *s) {
if (s->server)
epoll_ctl(s->server->epoll_fd, EPOLL_CTL_DEL, s->fd, NULL);
if (s->server)
epoll_ctl(s->server->epoll_fd, EPOLL_CTL_DEL, s->fd, NULL);
-
assert_se(close_nointr(s->fd) == 0
);
+
close_nointr_nofail(s->fd
);
}
free(s->process);
}
free(s->process);
@@
-315,12
+305,12
@@
static int stream_new(Server *s, int server_fd) {
if (s->n_streams >= STREAMS_MAX) {
log_warning("Too many connections, refusing connection.");
if (s->n_streams >= STREAMS_MAX) {
log_warning("Too many connections, refusing connection.");
-
assert_se(close_nointr(fd) == 0
);
+
close_nointr_nofail(fd
);
return 0;
}
if (!(stream = new0(Stream, 1))) {
return 0;
}
if (!(stream = new0(Stream, 1))) {
-
assert_se(close_nointr(fd) == 0
);
+
close_nointr_nofail(fd
);
return -ENOMEM;
}
return -ENOMEM;
}
@@
-409,16
+399,16
@@
static void server_done(Server *s) {
stream_free(s->streams);
for (i = 0; i < s->n_server_fd; i++)
stream_free(s->streams);
for (i = 0; i < s->n_server_fd; i++)
-
assert_se(close_nointr(SERVER_FD_START+i) == 0
);
+
close_nointr_nofail(SERVER_FD_START+i
);
if (s->syslog_fd >= 0)
if (s->syslog_fd >= 0)
-
assert_se(close_nointr(s->syslog_fd) == 0
);
+
close_nointr_nofail(s->syslog_fd
);
if (s->epoll_fd >= 0)
if (s->epoll_fd >= 0)
-
assert_se(close_nointr(s->epoll_fd) == 0
);
+
close_nointr_nofail(s->epoll_fd
);
if (s->kmsg_fd >= 0)
if (s->kmsg_fd >= 0)
-
assert_se(close_nointr(s->kmsg_fd) == 0
);
+
close_nointr_nofail(s->kmsg_fd
);
}
static int server_init(Server *s, unsigned n_sockets) {
}
static int server_init(Server *s, unsigned n_sockets) {
@@
-564,7
+554,7
@@
int main(int argc, char *argv[]) {
if (k <= 0)
break;
if (k <= 0)
break;
- if ((
r
= process_event(&server, &event)) < 0)
+ if ((
k
= process_event(&server, &event)) < 0)
goto fail;
}
r = 0;
goto fail;
}
r = 0;