summaryrefslogtreecommitdiff
path: root/community/cherokee/cherokee-admin-socket-bind.patch
blob: 0b266a245eacf4557413c83e381b6b8e17ad7022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
diff --git a/cherokee/main_admin.c b/cherokee/main_admin.c
index 861473f..e52b2d6 100644
--- a/cherokee/main_admin.c
+++ b/cherokee/main_admin.c
@@ -89,9 +89,9 @@ find_empty_port (int starting, int *port)
 	cherokee_buffer_add_str (&bind_, "127.0.0.1");
 
 	cherokee_socket_init (&s);
-	cherokee_socket_create_fd (&s, AF_INET);
 
 	while (true) {
+		cherokee_socket_create_fd (&s, AF_INET);
 		ret = cherokee_socket_bind (&s, p, &bind_);
 		if (ret == ret_ok)
 			break;
@@ -104,6 +104,7 @@ find_empty_port (int starting, int *port)
 		}
 	}
 
+	cherokee_socket_close (&s);
 	cherokee_socket_mrproper (&s);
 	cherokee_buffer_mrproper (&bind_);