summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-08-11 22:54:14 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2018-08-11 22:54:14 +0100
commitfdf4a5b7bc044ea6d26d8cb1e6835fada53c5f34 (patch)
tree77f24d9b067c78013034bdc7c95a5f13bdb86243 /vio
parent7a022d706155cb2ac00936d6829883b40af7f147 (diff)
downloadmariadb-git-fdf4a5b7bc044ea6d26d8cb1e6835fada53c5f34.tar.gz
MDEV-16277 tcp_nodelay session variable to enable / disable Nagle algorithm
Diffstat (limited to 'vio')
-rw-r--r--vio/viosocket.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index d34bb13b1bd..05c20c58bf8 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -435,8 +435,34 @@ int vio_socket_timeout(Vio *vio,
DBUG_RETURN(ret);
}
+/* Set TCP_NODELAY (disable Nagle's algorithm */
+int vio_nodelay(Vio *vio, my_bool on)
+{
+ int r;
+ int no_delay= MY_TEST(on);
+ DBUG_ENTER("vio_nodelay");
+
+ if (vio->type == VIO_TYPE_NAMEDPIPE || vio->type == VIO_TYPE_SHARED_MEMORY)
+ {
+ DBUG_RETURN(0);
+ }
+
+ r = mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_NODELAY,
+ IF_WIN((const char*), (void*)) &no_delay,
+ sizeof(no_delay));
+
+ if (r)
+ {
+ DBUG_PRINT("warning",
+ ("Couldn't set socket option for fast send, error %d",
+ socket_errno));
+ r = -1;
+ }
+ DBUG_PRINT("exit", ("%d", r));
+ DBUG_RETURN(r);
+}
-int vio_fastsend(Vio * vio __attribute__((unused)))
+int vio_fastsend(Vio * vio)
{
int r=0;
DBUG_ENTER("vio_fastsend");
@@ -454,18 +480,7 @@ int vio_fastsend(Vio * vio __attribute__((unused)))
}
#endif /* IPTOS_THROUGHPUT */
if (!r)
- {
-#ifdef __WIN__
- BOOL nodelay= 1;
-#else
- int nodelay = 1;
-#endif
-
- r= mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_NODELAY,
- IF_WIN((const char*), (void*)) &nodelay,
- sizeof(nodelay));
-
- }
+ r = vio_nodelay(vio, TRUE);
if (r)
{
DBUG_PRINT("warning",