|
Zbigniew Jędrzejewski-Szmek |
126222 |
From f1a638c065df3432bb69cc664b5425b96de13325 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
Date: Sat, 14 Dec 2013 11:54:26 -0500
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
Subject: [PATCH] logging: reduce send timeout to something more sensible
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
For a user, the timeout of 1 min per message seems equivalent to a hang.
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
If journald cannot process a message from PID1 for 10 ms then something
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
is significantly wrong. It's better to lose the message and continue.
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
src/shared/log.c | 5 ++++-
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
src/shared/time-util.c | 7 +++----
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
2 files changed, 7 insertions(+), 5 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
diff --git a/src/shared/log.c b/src/shared/log.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
index de770ca..2267764 100644
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
--- a/src/shared/log.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+++ b/src/shared/log.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
@@ -126,7 +126,10 @@ static int create_log_socket(int type) {
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
/* We need a blocking fd here since we'd otherwise lose
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
messages way too early. However, let's not hang forever in the
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
unlikely case of a deadlock. */
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
- timeval_store(&tv, 1*USEC_PER_MINUTE);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ if (getpid() == 1)
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ timeval_store(&tv, 10 * USEC_PER_MSEC);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ else
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ timeval_store(&tv, 10 * USEC_PER_SEC);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
return fd;
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
index d31401b..505b280 100644
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
--- a/src/shared/time-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+++ b/src/shared/time-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
@@ -141,12 +141,11 @@ struct timeval *timeval_store(struct timeval *tv, usec_t u) {
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
if (u == (usec_t) -1) {
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
tv->tv_sec = (time_t) -1;
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
tv->tv_usec = (suseconds_t) -1;
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
- return tv;
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ } else {
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ tv->tv_sec = (time_t) (u / USEC_PER_SEC);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
+ tv->tv_usec = (suseconds_t) (u % USEC_PER_SEC);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
- tv->tv_sec = (time_t) (u / USEC_PER_SEC);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
- tv->tv_usec = (suseconds_t) (u % USEC_PER_SEC);
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
return tv;
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
126222 |
|