dmitry          Tue Dec  5 08:55:34 2006 UTC

  Modified files:              
    /php-src/sapi/cgi   fastcgi.c 
  Log:
  Fixed FastCGI impersonation for persistent connections on Windows
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/fastcgi.c?r1=1.25&r2=1.26&diff_format=u
Index: php-src/sapi/cgi/fastcgi.c
diff -u php-src/sapi/cgi/fastcgi.c:1.25 php-src/sapi/cgi/fastcgi.c:1.26
--- php-src/sapi/cgi/fastcgi.c:1.25     Mon Oct 16 10:47:23 2006
+++ php-src/sapi/cgi/fastcgi.c  Tue Dec  5 08:55:34 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: fastcgi.c,v 1.25 2006/10/16 10:47:23 dmitry Exp $ */
+/* $Id: fastcgi.c,v 1.26 2006/12/05 08:55:34 dmitry Exp $ */
 
 #include "php.h"
 #include "fastcgi.h"
@@ -616,6 +616,13 @@
        if (destroy) {
                zend_hash_destroy(&req->env);
        }
+
+#ifdef _WIN32
+       if (is_impersonate) {
+               RevertToSelf();
+       }
+#endif
+
        if ((force || !req->keep) && req->fd >= 0) {
 #ifdef _WIN32
                HANDLE pipe = (HANDLE)_get_osfhandle(req->fd);
@@ -624,9 +631,6 @@
                        FlushFileBuffers(pipe);
                }
                DisconnectNamedPipe(pipe);
-               if (is_impersonate) {
-                       RevertToSelf();
-               }
 #else
                if (!force) {
                        char buf[8];
@@ -673,12 +677,7 @@
                                        }
                                }
                                CloseHandle(ov.hEvent);
-                               if (is_impersonate && 
!ImpersonateNamedPipeClient(pipe)) {
-                                       DisconnectNamedPipe(pipe);
-                                       req->fd = -1;
-                               } else {
-                                       req->fd = req->listen_socket;
-                               }
+                               req->fd = req->listen_socket;
                                FCGI_UNLOCK(req->listen_socket);
 #else
                                {
@@ -718,6 +717,15 @@
                        return -1;
                }
                if (fcgi_read_request(req)) {
+#ifdef _WIN32
+                       if (is_impersonate) {
+                               pipe = (HANDLE)_get_osfhandle(req->fd);
+                               if (!ImpersonateNamedPipeClient(pipe)) {
+                                       fcgi_close(req, 1, 1);
+                                       continue;
+                               }
+                       }
+#endif
                        return req->fd;
                } else {
                        fcgi_close(req, 1, 1);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to