summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-05-10 15:21:02 +0000
committerDmitry Stogov <dmitry@php.net>2007-05-10 15:21:02 +0000
commit6e8438633bdccfbfab896b5c6754fc024edd1eea (patch)
treef22368247b1dd09706d5b92a8c955ddde6d90674
parentfb045249e572c922fc7a2ea50cc8a428ab3607c6 (diff)
downloadphp-git-6e8438633bdccfbfab896b5c6754fc024edd1eea.tar.gz
Fixed bug #41291 (FastCGI does not set SO_REUSEADDR). (fmajid at kefta dot com)
-rw-r--r--NEWS2
-rw-r--r--sapi/cgi/fastcgi.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 96d588ec18..8489254b45 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PHP NEWS
- Fixed bug #41304 (compress.zlib temp files left). (Dmitry)
- Fixed bug #41293 (Fixed creation of HTTP_RAW_POST_DATA when there is no
default post handler). (Ilia)
+- Fixed bug #41291 (FastCGI does not set SO_REUSEADDR).
+ (fmajid at kefta dot com, Dmitry)
- Fixed gd build when used with freetype 1.x (Pierre, Tony)
- Fixed bug #41287 (Namespace functions don't allow xmlns definition to be
optional). (Rob)
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 73f12844d9..950b226790 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -345,6 +345,13 @@ int fcgi_listen(const char *path, int backlog)
int listen_socket;
sa_t sa;
socklen_t sock_len;
+#ifdef SO_REUSEADDR
+# ifdef _WIN32
+ BOOL reuse = 1;
+# else
+ int reuse = 1;
+# endif
+#endif
if ((s = strchr(path, ':'))) {
port = atoi(s+1);
@@ -434,6 +441,9 @@ int fcgi_listen(const char *path, int backlog)
/* Create, bind socket and start listen on it */
if ((listen_socket = socket(sa.sa.sa_family, SOCK_STREAM, 0)) < 0 ||
+#ifdef SO_REUSEADDR
+ setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, sizeof(reuse)) < 0 ||
+#endif
bind(listen_socket, (struct sockaddr *) &sa, sock_len) < 0 ||
listen(listen_socket, backlog) < 0) {