From: Timo Sirainen Date: Fri, 10 May 2019 15:06:46 +0000 (+0300) Subject: lib: Make sure uncorking ostream-file flushes network output immediately X-Git-Tag: 2.3.9~501 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45976e226c04500886a73bcef7af9d2c4154e338;p=thirdparty%2Fdovecot%2Fcore.git lib: Make sure uncorking ostream-file flushes network output immediately 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. --- diff --git a/src/lib/ostream-file.c b/src/lib/ostream-file.c index 5600d80a58..854fcae638 100644 --- a/src/lib/ostream-file.c +++ b/src/lib/ostream-file.c @@ -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; } }