RE: [PHP-DEV] FastCGI unix sockets support patch
| From: | Dmitry Stogov | Date: | Mon, 20 Mar 2006 10:44:30 +0000 |
| Subject: | RE: [PHP-DEV] FastCGI unix sockets support patch | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-22535@lists.php.net to get a copy of this message | ||
Hi Rostislav,
PHP HEAD and PHP_5_1 (5.1.3) don't use libfcgi any more.
They use simplest and smallest replacement library.
Please look into CVS code and provide a patch for it (if necessary).
Thanks. Dmitry.
> -----Original Message-----
> From: Rostislav Krasny [mailto:rosti.bsd@gmail.com]
> Sent: Monday, March 20, 2006 11:46 AM
> To: internals@lists.php.net
> Subject: [PHP-DEV] FastCGI unix sockets support patch
>
>
> Hi,
>
> According to a 'php -h' output of php-cgi 5.1.2 the FastCGI
> can be used only by TCP/IP:
>
> -b <address:port>|<port> 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 <address:port>"
> 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.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>