[evolution-data-server] Disable Nagle algorithm for IMAP connections.



commit 7672bef4e3cb513e6a27aae5868befd63b81bd71
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Nov 14 08:47:41 2013 -0500

    Disable Nagle algorithm for IMAP connections.
    
    I think I understand why this was done for the old CamelTcpStream:
    the Nagle algorithm interferes with the pipelining of IMAP commands.
    I do seem to notice some improved responsiveness after disabling this.
    Tried to provide a clearer explanation in the code this time.

 camel/providers/imapx/camel-imapx-server.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index bbecbf5..da9fd27 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
+#include <gio/gnetworking.h>
 
 #include "camel-imapx-server.h"
 
@@ -4213,6 +4214,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
        CamelSettings *settings;
        GIOStream *base_stream;
        GIOStream *tls_stream;
+       GSocket *socket;
        guint len;
        guchar *token;
        gint tok;
@@ -4270,6 +4272,19 @@ imapx_connect_to_server (CamelIMAPXServer *is,
                goto exit;
        }
 
+       /* Disable the Nagle algorithm with TCP_NODELAY, since IMAP
+        * commands should be issued immediately even we've not yet
+        * received a response to a previous command. */
+       socket = g_socket_connection_get_socket (
+               G_SOCKET_CONNECTION (base_stream));
+       g_socket_set_option (
+               socket, IPPROTO_TCP, TCP_NODELAY, 1, &local_error);
+       if (local_error != NULL) {
+               /* Failure to set the socket option is non-fatal. */
+               g_warning ("%s: %s", G_STRFUNC, local_error->message);
+               g_clear_error (&local_error);
+       }
+
        imapx_stream = camel_imapx_stream_new (stream);
 
        /* CamelIMAPXServer takes ownership of the IMAPX stream.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]