Re: Error : Accessing fast-cgi on linux

Mark Brown (mbrown@OpenMarket.com)
Wed, 12 Jun 1996 17:45:54 -0400

Message-Id: <199606122145.RAA00452@breckenridge.openmarket.com>
To: fastcgi-developers@OpenMarket.com
Subject: Re: Error : Accessing fast-cgi on linux 
In-Reply-To: John Weholdt's message of "Wed, 12 Jun 1996 22:31:38 BST."
             <Pine.LNX.3.91.960612222134.13750A-100000@login.bigblue.no> 
Date: Wed, 12 Jun 1996 17:45:54 -0400
From: Mark Brown <mbrown@OpenMarket.com>


John Weholdt asks:

    Is there any that has a working GetStreamSize for Linux systems?

Yes, sorry I've been so slow to get the Hypermail archive up:

------- Forwarded Message
From: Andrew Kuchling <amk@magnet.com>
Subject: Linux fixes for mod_fastcgi.c
To: fastcgi-developers@openmarket.com
Date: Tue, 4 Jun 1996 19:27:07 -0400 (EDT)


	The appended patch seems to make mod_fastcgi.c 1.2 work with
Apache 1.0.5 on Linux.

One thing I noticed that may be a bug waiting to happen, in FastCgiHandler():

{
    FastCgiServerInfo *serverInfoPtr;
    FastCgiInfo *infoPtr;
    int longjmp_val;
    OS_IpcAddr *ipcAddrPtr;

    longjmp_val = setjmp(jmp_env);
    if (longjmp_val == FCGI_ERROR) {
      if (infoPtr)
	FcgiCleanUp(infoPtr); 
      return SERVER_ERROR;
    }
 
	Shouldn't infoPtr be initialized to NULL?  What if setjmp()
fails and infoPtr contains some non-NULL garbage value?

	Also, if there are no AppClass directives in srm.conf, Apache
segfaults in free() on trying to access a FastCGI script; I'm still
searching for the cause of this.

	Andrew Kuchling
	amk@magnet.com


- --- mod_fastcgi.c       1996/06/04 21:44:39     1.2
+++ mod_fastcgi.c       1996/06/04 23:24:45
@@ -32,6 +32,9 @@
 #include <errno.h>
 #include <limits.h>
 #include <sys/types.h>
+#ifdef __linux
+#include <sys/time.h>
+#endif
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -3429,7 +3432,11 @@
  */
 int GetStreamSize(FILE *fp)
 {
+#ifdef _STDIO_USES_IOSTREAM
+  return ((fp->_IO_read_end) - (fp->_IO_read_ptr));
+#else
   return fp->_cnt;
+#endif
 }

 int GetFromStream(FILE *fp, char **buf)

------- End of Forwarded Message