]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: fix TLS log buffer on NetBSD
authorDavid Lamparter <equinox@diac24.net>
Sun, 19 Jul 2020 09:14:48 +0000 (11:14 +0200)
committerDavid Lamparter <equinox@diac24.net>
Mon, 20 Jul 2020 04:30:00 +0000 (06:30 +0200)
... this didn't work on NetBSD.  Like, at all.  It returns a positive
error code from posix_fallocate() and then we bang our head against a
brick wall trying to write to the mmap'd buffer.

Signed-off-by: David Lamparter <equinox@diac24.net>
(cherry picked from commit 6a3b431b85088d2d76a14d6c22ee85bdc5465c8c)

lib/zlog.c

index 45726755f8d397a04f3dc819865906aa4a09ad42..8dfd20371b8263425d4a21feee9f9f498a96075e 100644 (file)
@@ -246,10 +246,10 @@ void zlog_tls_buffer_init(void)
        fchown(mmfd, zlog_uid, zlog_gid);
 
 #ifdef HAVE_POSIX_FALLOCATE
-       if (posix_fallocate(mmfd, 0, TLS_LOG_BUF_SIZE) < 0) {
-#else
-       if (ftruncate(mmfd, TLS_LOG_BUF_SIZE) < 0) {
+       if (posix_fallocate(mmfd, 0, TLS_LOG_BUF_SIZE) != 0)
+       /* note next statement is under above if() */
 #endif
+       if (ftruncate(mmfd, TLS_LOG_BUF_SIZE) < 0) {
                zlog_err("failed to allocate thread log buffer \"%s\": %s",
                         mmpath, strerror(errno));
                goto out_anon_unlink;