]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Make sure uncorking ostream-file flushes network output immediately
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 10 May 2019 15:06:46 +0000 (18:06 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 14 May 2019 07:33:46 +0000 (07:33 +0000)
TCP_CORK and TCP_NODELAY are separate things, but we'll treat them similarly
for our ostream corking API. It was always intended that all data written
inside corking would be delayed until uncork, and immediately sent
afterwards.

This change removes unnecessary extra 40ms delays, which may happen when
proxying.

src/lib/ostream-file.c

index 5600d80a5897c0c0a4b657dbaea7c435a3061547..854fcae638aa29649dee0aa69e3a37d07b34bfb1 100644 (file)
@@ -359,6 +359,13 @@ static void o_stream_file_cork(struct ostream_private *stream, bool set)
                                fstream->no_socket_cork = TRUE;
                        fstream->socket_cork_set = FALSE;
                }
+               if (set) {
+                       /* Uncorking - send all the pending data immediately.
+                          Remove nodelay immediately afterwards, so if any
+                          output is sent outside corking it may get delayed. */
+                       net_set_tcp_nodelay(fstream->fd, TRUE);
+                       net_set_tcp_nodelay(fstream->fd, FALSE);
+               }
                stream->corked = set;
        }
 }