]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: fd-util - Ignore ECONNRESET when closing fd
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 21 Dec 2020 09:50:51 +0000 (11:50 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 12 Jan 2021 07:01:22 +0000 (07:01 +0000)
This happens e.g. on FreeBSD when closing a socket that has not been
fully flushed to client. Since we can't do anything about that,
we might as well just ignore it.

src/lib/fd-util.c

index 302beea709d9559ae48117fc05aa490e64d6798e..01315bc417222352ffadcbd287a9f8e7f34b4023 100644 (file)
@@ -151,7 +151,10 @@ void i_close_fd_path(int *fd, const char *path, const char *arg,
        }
 
        saved_errno = errno;
-       if (unlikely(close(*fd) < 0))
+       /* Ignore ECONNRESET because we don't really care about it here,
+          as we are closing the socket down in any case. There might be
+          unsent data but nothing we can do about that. */
+       if (unlikely(close(*fd) < 0 && errno != ECONNRESET))
                i_error("%s: close(%s%s%s) @ %s:%d failed (fd=%d): %m",
                        func, arg,
                        (path == NULL) ? "" : " = ",