Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22531 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68095 invoked by uid 1010); 20 Mar 2006 08:46:07 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 68080 invoked from network); 20 Mar 2006 08:46:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2006 08:46:07 -0000 X-Host-Fingerprint: 212.143.154.227 bb154227.bb.netvision.net.il Received: from ([212.143.154.227:26958] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 84/4F-55982-ECB6E144 for ; Mon, 20 Mar 2006 03:46:06 -0500 To: internals@lists.php.net Date: Mon, 20 Mar 2006 10:46:02 +0200 Message-ID: <20060320104602.9e202787.rosti.bsd@gmail.com> X-Newsreader: Sylpheed version 2.2.3 (GTK+ 2.8.16; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Posted-By: 212.143.154.227 Subject: FastCGI unix sockets support patch From: rosti.bsd@gmail.com (Rostislav Krasny) Hi, According to a 'php -h' output of php-cgi 5.1.2 the FastCGI can be used only by TCP/IP: -b | Bind Path for external FASTCGI Server mode But according to the code FastCGI could also be used by UNIX sockets. According to the code if the "-b " option is used and the port number is illegal or omitted then all the "address:port" string assumed as a UNIX socket name. That means that the UNIX socket should allways include a ":" in its filename. My patch eliminate this limitation. After applying it one should use "-b socket:" for UNIX sockets and "-b address:port" or "-b port" for TCP/IP. And if the port number is illegal, an error message is printed. If the "-b socket:" format is used the ":" is not added to the UNIX socket filename. What do you think about following patch? --- sapi/cgi/libfcgi/os_unix.c.orig Sun Dec 7 14:59:54 2003 +++ sapi/cgi/libfcgi/os_unix.c Mon Mar 20 09:28:28 2006 @@ -299,13 +299,15 @@ char host[MAXPATHLEN]; strlcpy(host, bindPath, MAXPATHLEN-1); - if((tp = strchr(host, ':')) != 0) { + if((tp = strrchr(host, ':')) != 0) { *tp++ = 0; - if((port = atoi(tp)) == 0) { - *--tp = ':'; - } else { + if (*tp != '\0') { + if((port = atoi(tp)) == 0) { + fprintf(stderr, "%s is illegal port number!\n", tp); + return -1; + } tcp = TRUE; - } + } } if(tcp) { if (!*host || !strcmp(host,"*")) { @@ -357,7 +359,7 @@ servLen = sizeof(sa.inetVariant); } else { unlink(bindPath); - if(OS_BuildSockAddrUn(bindPath, &sa.unixVariant, &servLen)) { + if(OS_BuildSockAddrUn(host, &sa.unixVariant, &servLen)) { fprintf(stderr, "Listening socket's path name is too long.\n"); return -1; } This patch changes an OS_CreateLocalIpcFd() function. The same change of OS_FcgiConnect() should probably be done as well. I didn't because the OS_FcgiConnect() isn't used anywhere by php.