]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-file,ostream-file - Ignore ECONNRESET
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 21 Dec 2020 09:51:36 +0000 (11:51 +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/istream-file.c
src/lib/ostream-file.c

index e89e9d46d7a2c3f6f1d1458ebb420b567e8298a9..f6e0c72c5df9040bd184bd0e0839ab17d926b007 100644 (file)
@@ -19,7 +19,10 @@ void i_stream_file_close(struct iostream_private *stream,
        struct istream_private *_stream = (struct istream_private *)stream;
 
        if (fstream->autoclose_fd && _stream->fd != -1) {
-               if (close(_stream->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 (close(_stream->fd) < 0 && errno != ECONNRESET) {
                        i_error("file_istream.close(%s) failed: %m",
                                i_stream_get_name(&_stream->istream));
                }
index f49c657ea07e2d22c460a66f9a282d098ae85115..fe4e592d75aa761d68ebb1c5924e85c57829d1b0 100644 (file)
@@ -38,7 +38,10 @@ static void stream_closed(struct file_ostream *fstream)
        io_remove(&fstream->io);
 
        if (fstream->autoclose_fd && fstream->fd != -1) {
-               if (close(fstream->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 (close(fstream->fd) < 0 && errno != ECONNRESET) {
                        i_error("file_ostream.close(%s) failed: %m",
                                o_stream_get_name(&fstream->ostream.ostream));
                }