瀏覽代碼

OSX does not support linger (1)

bel 8 年之前
父節點
當前提交
96b94a8a28
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/civetweb.c

+ 3 - 2
src/civetweb.c

@@ -12358,6 +12358,7 @@ close_socket_gracefully(struct mg_connection *conn)
 	} while (n > 0);
 #endif
 
+#if !defined(__MACH__)
 	/* Set linger option to avoid socket hanging out after close. This
 	 * prevent ephemeral port exhaust problem under high QPS. */
 	linger.l_onoff = 1;
@@ -12378,8 +12379,7 @@ close_socket_gracefully(struct mg_connection *conn)
 	} else if (error_code == ECONNRESET) {
 		/* Socket already closed by client/peer, close socket without linger */
 	} else {
-
-
+    
 		/* Set linger timeout */
 		if (setsockopt(conn->client.sock,
 		               SOL_SOCKET,
@@ -12392,6 +12392,7 @@ close_socket_gracefully(struct mg_connection *conn)
 			       strerror(ERRNO));
 		}
 	}
+#endif
 
 	/* Now we know that our FIN is ACK-ed, safe to close */
 	closesocket(conn->client.sock);