]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: i_close_fd_path() - Replace assert with more descriptive panic
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 1 Jul 2018 09:58:05 +0000 (12:58 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 1 Jul 2018 15:30:12 +0000 (15:30 +0000)
Since this function can be called from so many places, it's easier to figure
out the bug if the panic message contains what called it.

src/lib/fd-util.c

index a57419fc62da548bef288f61bb1913f577ee1b5d..45dcfcf2d945747f8548f86c31461fee744a39d7 100644 (file)
@@ -140,7 +140,13 @@ void i_close_fd_path(int *fd, const char *path, const char *arg,
        if (*fd == -1)
                return;
 
-       i_assert(*fd > 0);
+       if (unlikely(*fd <= 0)) {
+               i_panic("%s: close(%s%s%s) @ %s:%d attempted with fd=%d",
+                       func, arg,
+                       (path == NULL) ? "" : " = ",
+                       (path == NULL) ? "" : path,
+                       file, line, *fd);
+       }
 
        saved_errno = errno;
        if (unlikely(close(*fd) < 0))