aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2012-10-18 12:31:52 +0200
committerHenrik Nord <[email protected]>2012-10-18 12:31:56 +0200
commitd24b8eb31fa21caa3862eba152e0b9c1146cb436 (patch)
tree93aca77406cf9f3225dfee52426ef8081b1c5510
parent9a993c9479b94309861b7620d56fd12cfcab5740 (diff)
parent292fd914db1cebcd4ed6589b26df3f1e3faf623b (diff)
downloadotp-d24b8eb31fa21caa3862eba152e0b9c1146cb436.tar.gz
otp-d24b8eb31fa21caa3862eba152e0b9c1146cb436.tar.bz2
otp-d24b8eb31fa21caa3862eba152e0b9c1146cb436.zip
Merge branch 'ar/odbc_nagel'
* ar/odbc_nagel: Under Unix enable TCP_NODELAY to disable Nagel's socket algorithm OTP-10506
-rw-r--r--lib/odbc/c_src/odbcserver.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c
index 6d4460014f..fe81d1dd3a 100644
--- a/lib/odbc/c_src/odbcserver.c
+++ b/lib/odbc/c_src/odbcserver.c
@@ -104,6 +104,7 @@
#ifdef UNIX
#include <unistd.h>
+#include <netinet/tcp.h>
#endif
#if defined WIN32
@@ -201,6 +202,7 @@ static byte *receive_msg(int socket);
static Boolean receive_msg_part(int socket, byte * buffer, size_t msg_len);
static Boolean send_msg_part(int socket, byte * buffer, size_t msg_len);
static void close_socket(int socket);
+static void tcp_nodelay(int sock);
#endif
static void clean_socket_lib(void);
@@ -1782,6 +1784,10 @@ static int connect_to_erlang(const char *port)
sin6.sin6_addr = in6addr_loopback;
if (connect(sock, (struct sockaddr*)&sin6, sizeof(sin6)) == 0) {
+ /* Enable TCP_NODELAY to disable Nagel's socket algorithm. (Removes ~40ms delay on Redhat ES 6). */
+ #ifdef UNIX
+ tcp_nodelay(sock);
+ #endif
return sock;
}
close_socket(sock);
@@ -1797,9 +1803,24 @@ static int connect_to_erlang(const char *port)
close_socket(sock);
DO_EXIT(EXIT_SOCKET_CONNECT);
}
+
+ /* Enable TCP_NODELAY to disable Nagel's socket algorithm. (Removes ~40ms delay on Redhat ES 6). */
+ #ifdef UNIX
+ tcp_nodelay(sock);
+ #endif
return sock;
}
+#ifdef UNIX
+static void tcp_nodelay(int sock)
+{
+ int flag = 1;
+ int result = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+ if (result < 0) {
+ DO_EXIT(EXIT_SOCKET_CONNECT);
+ }
+}
+#endif
#ifdef WIN32
static void close_socket(SOCKET socket)
{