]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: ostream-file - Set TCP_QUICKACK whenever uncorking
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 6 Nov 2019 12:39:25 +0000 (14:39 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 12 Nov 2019 07:30:50 +0000 (07:30 +0000)
This reduces latency in some situations.

src/lib/ostream-file-private.h
src/lib/ostream-file.c

index bb0acb25dfd1c969d4f3a3cd3a039200f6f2f4cf..2d58933559efc05afa29588ec2cf6eefe027fd21 100644 (file)
@@ -25,6 +25,7 @@ struct file_ostream {
        bool socket_cork_set:1;
        bool no_socket_cork:1;
        bool no_socket_nodelay:1;
+       bool no_socket_quickack:1;
        bool no_sendfile:1;
        bool autoclose_fd:1;
 };
index 82bf729ac0094a0cc30ffdd98eafac50e07aedac..e3a85e2b4fdd770d244ec42aa1485b1182323944 100644 (file)
@@ -387,6 +387,12 @@ static void o_stream_file_cork(struct ostream_private *stream, bool set)
                           output is sent outside corking it may get delayed. */
                        o_stream_tcp_flush_via_nodelay(fstream);
                }
+               if (!set && !fstream->no_socket_quickack) {
+                       /* Uncorking - disable delayed ACKs to reduce latency.
+                          Note that this needs to be set repeatedly. */
+                       if (net_set_tcp_quickack(fstream->fd, TRUE) < 0)
+                               fstream->no_socket_quickack = TRUE;
+               }
                stream->corked = set;
        }
 }
@@ -1026,6 +1032,7 @@ static void fstream_init_file(struct file_ostream *fstream)
        if (S_ISREG(st.st_mode)) {
                fstream->no_socket_cork = TRUE;
                fstream->no_socket_nodelay = TRUE;
+               fstream->no_socket_quickack = TRUE;
                fstream->file = TRUE;
        }
 }
@@ -1056,10 +1063,12 @@ struct ostream * o_stream_create_fd_common(int fd, size_t max_buffer_size,
                        fstream->no_sendfile = TRUE;
                        fstream->no_socket_cork = TRUE;
                        fstream->no_socket_nodelay = TRUE;
+                       fstream->no_socket_quickack = TRUE;
                } else if (local_ip.family == 0) {
                        /* UNIX domain socket */
                        fstream->no_socket_cork = TRUE;
                        fstream->no_socket_nodelay = TRUE;
+                       fstream->no_socket_quickack = TRUE;
                }
        }