From: Vladimír Čunát Date: Tue, 9 Jun 2020 04:24:42 +0000 (+0200) Subject: gc: fix flushing of messages to logs X-Git-Tag: v5.1.2~3^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e50395a472bfc8bd37df32215e9fcc8ec12e24cd;p=thirdparty%2Fknot-resolver.git gc: fix flushing of messages to logs There were the usual effects: very incorrect timestamps (even by days), and I suspect we could even lose some logs completely. --- diff --git a/NEWS b/NEWS index 5d50772f7..fe2ebe2a8 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ Bugfixes - hints module: NODATA answers also for non-address queries (!1005) - tls: send alert to peer if handshake fails (!1007) - cache: fix interaction between LMDB locks and preallocation (!1013) +- cache garbage collector: fix flushing of messages to logs (!1009) Knot Resolver 5.1.1 (2020-05-19) diff --git a/utils/cache_gc/main.c b/utils/cache_gc/main.c index 6738ba03d..cd868553f 100644 --- a/utils/cache_gc/main.c +++ b/utils/cache_gc/main.c @@ -56,6 +56,11 @@ static long get_nonneg_optarg() int main(int argc, char *argv[]) { printf("Knot Resolver Cache Garbage Collector v. %s\n", KR_CACHE_GC_VERSION); + if (setvbuf(stdout, NULL, _IONBF, 0) || setvbuf(stderr, NULL, _IONBF, 0)) { + fprintf(stderr, "Failed to to set output buffering (ignored): %s\n", + strerror(errno)); + fflush(stderr); + } signal(SIGTERM, got_killed); signal(SIGKILL, got_killed);