Browse Source

Merge commit '0676a1a' into cg_merges_20130524b

Conflicts:
	util.c
Luke Dashjr 12 years ago
parent
commit
ec01f46d14
1 changed files with 8 additions and 9 deletions
  1. 8 9
      util.c

+ 8 - 9
util.c

@@ -238,19 +238,21 @@ static int keep_sockalive(SOCKETTYPE fd)
 {
 {
 	const int tcp_keepidle = 45;
 	const int tcp_keepidle = 45;
 	const int tcp_keepintvl = 30;
 	const int tcp_keepintvl = 30;
-	const int keepalive = 1;
+	const int tcp_one = 1;
 	int ret = 0;
 	int ret = 0;
 
 
+	if (unlikely(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const char *)&tcp_one, sizeof(tcp_one))))
+		ret = 1;
 
 
-#ifndef WIN32
-	const int tcp_keepcnt = 1;
+	if (!opt_delaynet)
+		if (unlikely(setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one))))
+			ret = 1;
 
 
-	if (unlikely(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive))))
-		ret = 1;
+#ifndef WIN32
 
 
 # ifdef __linux
 # ifdef __linux
 
 
-	if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_keepcnt, sizeof(tcp_keepcnt))))
+	if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_one, sizeof(tcp_one))))
 		ret = 1;
 		ret = 1;
 
 
 	if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle))))
 	if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle))))
@@ -276,9 +278,6 @@ static int keep_sockalive(SOCKETTYPE fd)
 
 
 	DWORD outputBytes;
 	DWORD outputBytes;
 
 
-	if (unlikely(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const char *)&keepalive, sizeof(keepalive))))
-		ret = 1;
-
 	if (unlikely(WSAIoctl(fd, SIO_KEEPALIVE_VALS, &vals, sizeof(vals), NULL, 0, &outputBytes, NULL, NULL)))
 	if (unlikely(WSAIoctl(fd, SIO_KEEPALIVE_VALS, &vals, sizeof(vals), NULL, 0, &outputBytes, NULL, NULL)))
 		ret = 1;
 		ret = 1;