]> granicus.if.org Git - php/commitdiff
Fixed bug #41291 (FastCGI does not set SO_REUSEADDR). (fmajid at kefta dot com)
authorDmitry Stogov <dmitry@php.net>
Thu, 10 May 2007 15:21:02 +0000 (15:21 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 10 May 2007 15:21:02 +0000 (15:21 +0000)
NEWS
sapi/cgi/fastcgi.c

diff --git a/NEWS b/NEWS
index 96d588ec18cbbf37ffb0c3a9c4c3e69bacffc49a..8489254b45d2246c9ec5f5427ab11954a2227ef9 100644 (file)
--- 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)
index 73f12844d9a7fcba11d541c1c6a1330df3a3974c..950b22679070892f7395d8b6f51f1ff7b533db32 100644 (file)
@@ -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) {