#40758 [Asn->Csd]: Test fcgi_is_fastcgi() is wrong on windows

From: Date: Wed, 28 Mar 2007 15:40:46 +0000
Subject: #40758 [Asn->Csd]: Test fcgi_is_fastcgi() is wrong on windows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110890@lists.php.net to get a copy of this message
 ID:               40758
 Updated by:       dmitry@php.net
 Reported By:      jostb2345 at yahoo dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         CGI related
 Operating System: Windows (all versions)
 PHP Version:      5.2.1
 Assigned To:      dmitry
 New Comment:

Fixed in CVS HEAD and PHP_5_2.


Previous Comments:
------------------------------------------------------------------------

[2007-03-23 09:06:44] dmitry@php.net

ok. I'll add socket support for win32, but I am not sure when I'll have
time for this work.

------------------------------------------------------------------------

[2007-03-13 16:29:28] jostb2345 at yahoo dot com

> May be older PHP versions were able to support sockets on win32, but
I
> have never seen any FastCGI plugin implmentation that passes
sockets.

PHPIntKitForWindows.zip

=> http://www.alphaworks.ibm.com/tech/phpintwasce/download


> Also I don't see any sockets advantages (only disadvantages).

I don't think named pipes work on all operating systems. Furthermore
Java supports only TCP socket communication (well, it is possible to
access Windows and Unix named pipes from Java. But one has to implement
it twice. RandomAccessFile on Windows, a pair of normal Files on Unix).


To be practical -- and for backward compatibility -- we need a working
TCP socket implementation on both operating systems. tcp sockets worked
in PHP versions < 5.2.0 and I don't see a good reason to drop this.


Regards,
Jost Boekemeier

------------------------------------------------------------------------

[2007-03-12 17:21:32] dmitry@php.net

yes. PHP expects pipe but not a socket.

In C you may even try to pass window HANDLE :)

May be older PHP versions were able to support sockets on win32, but I
have never seen any FastCGI plugin implmentation that passes sockets.
Also I don't see any sockets advantages (only disadvantages).


------------------------------------------------------------------------

[2007-03-09 17:06:35] jostb2345 at yahoo dot com

> I don't understand for what reason some program passes stdout to
> PHP

Because I thought you need to distinguish sockets from named pipes.
I have attached code which crashes php since 5.2.0.


Regards,
Jost Boekemeier

------------------------------------------------------------------------

[2007-03-09 17:01:01] jostb2345 at yahoo dot de

# include <windows.h>
# include <winsock2.h>
# define close closesocket

term() {
  printf("err:%d", (GetLastError()));
  exit(1);
}

struct sockaddr_in saddr;
main() {
  SOCKET listen_handle;
  SOCKADDR_IN saServer;		
  char *cmd = "php-cgi.exe";
  STARTUPINFO su_info;
  SECURITY_ATTRIBUTES sa = { 0 };
  WORD wVersionRequested = MAKEWORD(1,1);
  WSADATA wsaData;
  int n = WSAStartup(wVersionRequested, &wsaData);
  if (wsaData.wVersion != wVersionRequested) term();

  listen_handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  
  saServer.sin_family = AF_INET;
  saServer.sin_addr.s_addr = INADDR_ANY;
  saServer.sin_port = htons(9667);

  n = bind(listen_handle, (LPSOCKADDR)&saServer, sizeof(struct
sockaddr));
  if (n == SOCKET_ERROR) term();

  n = listen(listen_handle, 20);
  if (n == SOCKET_ERROR) term();
  

  ZeroMemory(&su_info, sizeof(STARTUPINFO));
  su_info.cb = sizeof(STARTUPINFO);
  su_info.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
  su_info.wShowWindow = SW_HIDE;
  su_info.hStdInput = listen_handle;
  su_info.hStdError	= INVALID_HANDLE_VALUE;
  su_info.hStdOutput = INVALID_HANDLE_VALUE;
  SetHandleInformation(su_info.hStdInput, HANDLE_FLAG_INHERIT, TRUE);

  PROCESS_INFORMATION p;
  if(CreateProcess(NULL, cmd, NULL, NULL, 1, 0, NULL, NULL, &su_info,
&p)) {
    CloseHandle(p.hThread); closesocket(listen_handle);
  } else {
    term();
  }
  if( WaitForSingleObject(p.hProcess, INFINITE) == WAIT_FAILED ){
    term();
   }
  WSACleanup();
}

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/40758

-- 
Edit this bug report at http://bugs.php.net/?id=40758&edit=1


Thread (11 messages)

« previous php.bugs (#110890) next »