You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Sam Robb <sr...@wisewire.com> on 1998/02/02 17:46:17 UTC

Patch for Win32 CGI bugs

All,

Patch for some Win32 CGI-related bugs, based off the Friday snapshot of
the source
from dev.apache.org/from-cvs/.  This is my first contribution, so please
let me know if
anything's incorrect or inappropriate.

Also, a while back, someone had some information on using cvs from NT to
access
the repositories for updates.  Whoever it was, can you repeat the info
and/or make it
available at dev.apache.org?  Thanks.

[1129] os-windows Hang on concurrent CGI invocations
[1607] os-windows apache 1.3b3 hangs on concurrent CGI (still) ref bug
1129
[1712] os-windows CGI-executables other than .exe won't execute

Definitely fixes 1712; possibly fixes the other two. Before the patch,
27 consecutive
cgi invocations would cause apache to hang; after the patch, I was
unable to reproduce
the effects (with either repeated or concurrent CGI requests).

- Samrobb (srobb@wisewire.com)
- WiseWire Corporation - The Content Agent Company
- http://www.wisewire.com
- http://www.lycos.com/webguides/webguides.html

The box said 'Requires Windows 95, or better.' So I bought a Macintosh.


diff -u f:\apache.org\src\os\win32\util_win32.c
f:\apache.src\src\os\win32\util_win32.c > f:\apache.dif\util_win32.txt

--- f:\apache.org\src\os\win32\util_win32.c	Fri Dec 26 15:00:12 1997
+++ f:\apache.src\src\os\win32\util_win32.c	Mon Feb 02 08:52:42 1998
@@ -89,6 +89,14 @@
  *
  *  1. Win32 doesn't deal with spaces in argv.
  *  2. Win95 doesn't like / in cmdname.
+ *
+ *  More:
+ *  3.  Win32 wants a '.' appended to bare filename (ex,
+ *      "script.") to indicate that yes, you really mean
+ *      that the file doesn't have an extension
+ *  4.  Win32 requires _flushall before spawn* (keeps
+ *      repeated CGI calls from hanging)
+ *  
  */
 
 #undef _spawnv
@@ -99,13 +107,22 @@
     const char *szArg;
     char *szCmd;
     char *s;
+    char *ext;
+    int cmdlen;
     
-    szCmd = _alloca(strlen(cmdname)+1);
+    cmdlen = strlen(cmdname);
+    szCmd = _alloca(cmdlen+2);
     strcpy(szCmd, cmdname);
     for (s = szCmd; *s; ++s)
         if (*s == '/')
             *s = '\\';
     
+    ext = strrchr(szCmd, '.');
+    if (!ext || ext < strrchr(szCmd, '\\')) {
+        szCmd[cmdlen] = '.';
+        szCmd[cmdlen+1] = '\0';
+    }
+
     for (n=0; argv[n]; ++n)
         ;
 
@@ -127,6 +144,7 @@
 
     aszArgs[n] = NULL;
 
+    _flushall();
     return _spawnv(mode, szCmd, aszArgs);
 }
 
@@ -138,13 +156,22 @@
     const char *szArg;
     char *szCmd;
     char *s;
+    char *ext;
+    int cmdlen;
     
-    szCmd = _alloca(strlen(cmdname)+1);
+    cmdlen = strlen(cmdname);
+    szCmd = _alloca(cmdlen+2);
     strcpy(szCmd, cmdname);
     for (s = szCmd; *s; ++s)
         if (*s == '/')
             *s = '\\';
     
+    ext = strrchr(szCmd, '.');
+    if (!ext || ext < strrchr(szCmd, '\\')) {
+        szCmd[cmdlen] = '.';
+        szCmd[cmdlen+1] = '\0';
+    }
+
     for (n = 0; argv[n] ; ++n)
         ;
 
@@ -166,6 +193,7 @@
 
     aszArgs[n] = NULL;
 
+    _flushall();
     return _spawnve(mode, szCmd, aszArgs, envp);
 }
 
@@ -178,13 +206,22 @@
     const char *const *aszEnv;
     char *szCmd;
     char *s;
-    
-    szCmd = _alloca(strlen(cmdname)+1);
+    char *ext;
+    int cmdlen;
+
+    cmdlen = strlen(cmdname);
+    szCmd = _alloca(cmdlen+2);
     strcpy(szCmd, cmdname);
     for (s = szCmd; *s; ++s)
         if(*s == '/')
             *s = '\\';
 
+    ext = strrchr(szCmd, '.');
+    if (!ext || ext < strrchr(szCmd, '\\')) {
+        szCmd[cmdlen] = '.';
+        szCmd[cmdlen+1] = '\0';
+    }
+
     va_start(vlist, cmdname);
     for (n = 0; va_arg(vlist, const char *); ++n)
         ;
@@ -212,5 +249,6 @@
     aszEnv = va_arg(vlist, const char *const *);
     va_end(vlist);
     
+    _flushall();
     return _spawnve(mode, szCmd, aszArgs, aszEnv);
 }


Re: Patch for Win32 CGI bugs

Posted by Ben Laurie <be...@algroup.co.uk>.
Sam Robb wrote:
> 
> All,
> 
> Patch for some Win32 CGI-related bugs, based off the Friday snapshot of
> the source
> from dev.apache.org/from-cvs/.  This is my first contribution, so please
> let me know if
> anything's incorrect or inappropriate.
> 
> Also, a while back, someone had some information on using cvs from NT to
> access
> the repositories for updates.  Whoever it was, can you repeat the info
> and/or make it
> available at dev.apache.org?  Thanks.
> 
> [1129] os-windows Hang on concurrent CGI invocations
> [1607] os-windows apache 1.3b3 hangs on concurrent CGI (still) ref bug
> 1129
> [1712] os-windows CGI-executables other than .exe won't execute
> 
> Definitely fixes 1712; possibly fixes the other two. Before the patch,
> 27 consecutive
> cgi invocations would cause apache to hang; after the patch, I was
> unable to reproduce
> the effects (with either repeated or concurrent CGI requests).

Actually, it doesn't fix 1712, because this is not what 1712 was
complaining about. OTOH, 1712 doesn't need fixing, coz it ain't broken.

However, your patch does make extensionless CGIs work, so I'm committing
the relevant parts.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: Patch for Win32 CGI bugs

Posted by Ben Laurie <be...@algroup.co.uk>.
Marc Slemko wrote:
> 
> This would be a good thing to get in before 1.3b4 (yea, yea, too late...
> Jim could make an exception, he is nice...) if someone can test it, but...
> I could never reproduce the problem.

I intend to test it ... but I have to find a few spare hours - it is
hard to be sure it has been fixed on my setup because it can easily take
30 minutes or more to go wrong. I've got to finish some paying work
before I can have a go (and its already 8:30 pm) but I'll see what I can
do...

Since it is a Win32 only patch, I'd hope Jim would let us sneak it in.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: Patch for Win32 CGI bugs

Posted by Marc Slemko <ma...@worldgate.com>.
This would be a good thing to get in before 1.3b4 (yea, yea, too late... 
Jim could make an exception, he is nice...) if someone can test it, but...
I could never reproduce the problem. 



On Sat, 7 Feb 1998, Ben Laurie wrote:

> Sam Robb wrote:
> > Also, a while back, someone had some information on using cvs from NT to
> > access
> > the repositories for updates.  Whoever it was, can you repeat the info
> > and/or make it
> > available at dev.apache.org?  Thanks.
> > 
> > [1129] os-windows Hang on concurrent CGI invocations
> > [1607] os-windows apache 1.3b3 hangs on concurrent CGI (still) ref bug
> > 1129
> > [1712] os-windows CGI-executables other than .exe won't execute
> > 
> > Definitely fixes 1712; possibly fixes the other two. Before the patch,
> > 27 consecutive
> > cgi invocations would cause apache to hang; after the patch, I was
> > unable to reproduce
> > the effects (with either repeated or concurrent CGI requests).
> 
> I'd like to know: do you have any reason to believe that this should
> have an impact on concurrent CGI, or was this just a wild guess?
> 
> Cheers,
> 
> Ben.
> 
> -- 
> Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
> Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
> and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
> A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
> London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache
> 


Re: Patch for Win32 CGI bugs

Posted by Ben Laurie <be...@algroup.co.uk>.
Sam Robb wrote:
> Also, a while back, someone had some information on using cvs from NT to
> access
> the repositories for updates.  Whoever it was, can you repeat the info
> and/or make it
> available at dev.apache.org?  Thanks.
> 
> [1129] os-windows Hang on concurrent CGI invocations
> [1607] os-windows apache 1.3b3 hangs on concurrent CGI (still) ref bug
> 1129
> [1712] os-windows CGI-executables other than .exe won't execute
> 
> Definitely fixes 1712; possibly fixes the other two. Before the patch,
> 27 consecutive
> cgi invocations would cause apache to hang; after the patch, I was
> unable to reproduce
> the effects (with either repeated or concurrent CGI requests).

I'd like to know: do you have any reason to believe that this should
have an impact on concurrent CGI, or was this just a wild guess?

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: Patch for Win32 CGI bugs

Posted by Ben Laurie <be...@algroup.co.uk>.
Marc Slemko wrote:
> 
> On Mon, 2 Feb 1998, Sam Robb wrote:
> 
> > All,
> >
> > Patch for some Win32 CGI-related bugs, based off the Friday snapshot of
> > the source
> > from dev.apache.org/from-cvs/.  This is my first contribution, so please
> > let me know if
> > anything's incorrect or inappropriate.
> 
> Yea, the fact that Windows sucks is inappropriate.  Please fix that.
> Thanks. <g>
> 
> I haven't had a chance to look at your patch yet in detail, but it seems
> like it could be reasonable.  It is very very very lame if that is what
> has to be done, but that isn't your fault.
> 
> Thanks for the effort, if it fixes the concurrent CGI hang thing I will be
> happy, although I never could reproduce it.  Don't doubt it exists though.

Does someone want to dig out the PRs (there's at least two) and see if
this patch does it for them? (I'll do it later if no-one else can be
bothered - gotta go and cook something before I die of hunger).

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: Patch for Win32 CGI bugs

Posted by Marc Slemko <ma...@worldgate.com>.
On Mon, 2 Feb 1998, Sam Robb wrote:

> All,
> 
> Patch for some Win32 CGI-related bugs, based off the Friday snapshot of
> the source
> from dev.apache.org/from-cvs/.  This is my first contribution, so please
> let me know if
> anything's incorrect or inappropriate.

Yea, the fact that Windows sucks is inappropriate.  Please fix that. 
Thanks. <g>

I haven't had a chance to look at your patch yet in detail, but it seems 
like it could be reasonable.  It is very very very lame if that is what
has to be done, but that isn't your fault.

Thanks for the effort, if it fixes the concurrent CGI hang thing I will be
happy, although I never could reproduce it.  Don't doubt it exists though.

> 
> Also, a while back, someone had some information on using cvs from NT to
> access
> the repositories for updates.  Whoever it was, can you repeat the info
> and/or make it
> available at dev.apache.org?  Thanks.

http://dev.apache.org/anoncvs.txt

cvs works the same way under NT, the only difference being that you
normally have to take greater pains to install it.

> --- f:\apache.org\src\os\win32\util_win32.c	Fri Dec 26 15:00:12 1997
> +++ f:\apache.src\src\os\win32\util_win32.c	Mon Feb 02 08:52:42 1998
> @@ -89,6 +89,14 @@
>   *
>   *  1. Win32 doesn't deal with spaces in argv.
>   *  2. Win95 doesn't like / in cmdname.
> + *
> + *  More:
> + *  3.  Win32 wants a '.' appended to bare filename (ex,
> + *      "script.") to indicate that yes, you really mean
> + *      that the file doesn't have an extension
> + *  4.  Win32 requires _flushall before spawn* (keeps
> + *      repeated CGI calls from hanging)
> + *  
>   */