summaryrefslogtreecommitdiffstats
path: root/main/uwsgi/0003-core-socket-move-listen-queue-size-checking-to-creat.patch
blob: c7ed55d04ce5f2673c2ae9b18d3b0144376103de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 51a8f31f17440702b308b15e0c9dd73255cbb572 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Wed, 1 Jan 2014 23:55:57 +0200
Subject: [PATCH 3/5] core/socket: move listen queue size checking to
 create_server_socket

---
 core/socket.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/core/socket.c b/core/socket.c
index ee63b98..3eed477 100644
--- a/core/socket.c
+++ b/core/socket.c
@@ -102,6 +102,15 @@ static int create_server_socket(int domain, int type) {
 				return -1;
 			}
 		}
+
+#ifdef __linux__
+		long somaxconn = uwsgi_num_from_file("/proc/sys/net/core/somaxconn", 1);
+		if (somaxconn > 0 && uwsgi.listen_queue > somaxconn) {
+			uwsgi_log("Listen queue size is greater than the system max net.core.somaxconn (%li).\n", somaxconn);
+			uwsgi_nuclear_blast();
+			return -1;
+		}
+#endif
 	}
 
 	return serverfd;
@@ -208,15 +217,6 @@ int bind_to_unix(char *socket_name, int listen_queue, int chmod_socket, int abst
 		return -1;
 	}
 
-#ifdef __linux__
-        long somaxconn = uwsgi_num_from_file("/proc/sys/net/core/somaxconn", 1);
-        if (somaxconn > 0 && uwsgi.listen_queue > somaxconn) {
-                uwsgi_log("Listen queue size is greater than the system max net.core.somaxconn (%li).\n", somaxconn);
-                uwsgi_nuclear_blast();
-                return -1;
-        }
-#endif
-
 	if (listen(serverfd, listen_queue) != 0) {
 		uwsgi_error("listen()");
 		uwsgi_nuclear_blast();
@@ -761,15 +761,6 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) {
 		return -1;
 	}
 
-#ifdef __linux__
-	long somaxconn = uwsgi_num_from_file("/proc/sys/net/core/somaxconn", 1);
-	if (somaxconn > 0 && uwsgi.listen_queue > somaxconn) {
-		uwsgi_log("Listen queue size is greater than the system max net.core.somaxconn (%li).\n", somaxconn);
-		uwsgi_nuclear_blast();
-		return -1;
-	}
-#endif
-
 	if (listen(serverfd, listen_queue) != 0) {
 		uwsgi_error("listen()");
 		uwsgi_nuclear_blast();
-- 
1.8.4.2