php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37238 fastcgi-isapi dll runs dynamic servers as filters rather than responders
Submitted: 2006-04-28 16:30 UTC Modified: 2007-03-03 23:54 UTC
From: barborak at basikgroup dot com Assigned: edink (profile)
Status: Closed Package: IIS related
PHP Version: 6CVS-2006-04-28 (CVS) OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: barborak at basikgroup dot com
New email:
PHP Version: OS:

 

 [2006-04-28 16:30 UTC] barborak at basikgroup dot com
Description:
------------
(I apologize if I am reporting this in the wrong place. It seems that Shane Caraveo's fastcgi-isapi module is now being maintained as part of the PHP project. This is a great DLL for general FastCGI applications and not just PHP. The problem I found relates to using it with Perl to run dynamic servers. As such, it's not terribly relevant to your work but I thought I'd report it along with patches.)

1. When using the fastcgi-isapi DLL to run dynamic servers, the dynamic servers are running as FastCGI filters rather than responders. This is due to a structure's member not being initialized.

2. When using perl as the server executable, it is sometimes necessary to include arguments like -T and -w. The Args value in the registry is being ignored for dynamic servers.

Here are the patches I applied to the code in CVS to fix these problems:

--- FCGIProcMgr.cpp     Thu Apr 27 14:46:38 2006
+++ FCGIProcMgr.cpp.new Thu Apr 27 14:45:54 2006
@@ -388,7 +388,10 @@
        proc->incServers = parent->incServers;
        proc->maxServers = parent->maxServers;
        proc->timeout = parent->timeout;
-       if (path) strncpy(proc->args, path, sizeof(proc->args)-1);
+       proc->isFilter = parent->isFilter;
+       *( proc->args ) = 0;
+       if (parent->args) strncpy(proc->args, parent->args,
sizeof(proc->args)-1);
+       if (path) strncpy(proc->args + strlen (proc->args), path,
sizeof(proc->args)-1 - strlen (proc->args) );
        strncpy(proc->bindPath, bindpath, sizeof(proc->bindPath)-1);
        if (dwServerImpersonate) {
                proc->env.putEnv("_FCGI_NTAUTH_IMPERSONATE_=1");

And I also needed this change to compile it on my machine:

--- fcgi_server.h       Thu Apr 27 14:46:38 2006
+++ fcgi_server.h.new   Thu Apr 27 14:43:46 2006
@@ -25,6 +25,10 @@
 #define FCGI_SERVER_VERSION "2.2.2 0.5.2 beta"
 #define FCGI_ENVIRON_VER "FCGI_SERVER_VERSION=" FCGI_SERVER_VERSION

+#if !defined (INVALID_FILE_ATTRIBUTES)
+#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+#endif
+
 extern void InitiateServers(char *szExtension);
 extern void CheckServers(char *szExtension); 

Given these changes and registry settings like the following, I was able to successfully run perl dynamic servers with the fastcgi-isapi module:

HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI\.pl

In this key, I added the following values:

AppPath REG_SZ c:\tools\perl\5.6.1\bin\MSWin32-x86\perl.exe
Args REG_SZ -T
BindPath REG_SZ

Note that the value of Args is "-T " (with a space). BindPath is empty. (Perhaps it's not necessary.)




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-30 22:20 UTC] edink@php.net
Could you please post this patch online somewhere?

I'll check it out.
 [2006-05-01 15:39 UTC] barborak at basikgroup dot com
i've posted the patches here:

http://www.basikgroup.com/temp/fastcgi_isapi_patches.zip

thanks,
mike
 [2007-03-03 23:54 UTC] edink@php.net
Not quite a year yet, but the patches have been applied :)

Precompiled file can be downloaded from:
http://pecl4win.php.net/download.php/dll/04d5c454937559f3ea031e8051b55625/isapi_fcgi.dll

Thanks!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 05:01:33 2025 UTC