add warning when in devkit and library hasn't been compiled yet
[catagits/fcgi2.git] / cgi-fcgi / cgi-fcgi.c
index 9de2f5a..4e03e4d 100644 (file)
@@ -11,7 +11,7 @@
  *
  */
 #ifndef lint
-static const char rcsid[] = "$Id: cgi-fcgi.c,v 1.7 1999/07/28 00:38:34 roberts Exp $";
+static const char rcsid[] = "$Id: cgi-fcgi.c,v 1.10 1999/08/27 19:39:17 roberts Exp $";
 #endif /* not lint */
 
 #include "fcgi_config.h"
@@ -346,6 +346,18 @@ static int webServerReadHandlerEOF;
                          * the Web server. Used in main to prevent
                          * rescheduling WebServerReadHandler. */
 
+static void WriteStdinEof(void)
+{
+    static int stdin_eof_sent = 0;
+
+    if (stdin_eof_sent)
+       return;
+
+    *((FCGI_Header *)fromWS.stop) = MakeHeader(FCGI_STDIN, requestId, 0, 0);
+    fromWS.stop += sizeof(FCGI_Header);
+    stdin_eof_sent = 1;
+}
+
 /*
  *----------------------------------------------------------------------
  *
@@ -373,6 +385,10 @@ static void WebServerReadHandler(ClientData clientData, int bytesRead)
     bytesToRead -= bytesRead;
     fromWS.stop = &fromWS.buff[sizeof(FCGI_Header) + bytesRead];
     webServerReadHandlerEOF = (bytesRead == 0);
+
+    if (bytesToRead <= 0)
+       WriteStdinEof();
+
     ScheduleIo();
 }
 \f
@@ -488,7 +504,8 @@ static void FCGI_Start(char *bindPath, char *appPath, int nServers)
 {
     int listenFd, i;
 
-    if((listenFd = OS_CreateLocalIpcFd(bindPath)) == -1) {
+    /* @@@ Should be able to pick up the backlog as an arg */
+    if((listenFd = OS_CreateLocalIpcFd(bindPath, 5)) == -1) {
         exit(OS_Errno);
     }
 
@@ -652,7 +669,7 @@ static int ParseArgs(int argc, char *argv[],
            }
        } else if(*appPathPtr == '\0') {
             strcpy(appPathPtr, argv[i]);
-        } else if(isdigit(argv[i][0]) && *nServersPtr == 0) {
+        } else if(isdigit((int)argv[i][0]) && *nServersPtr == 0) {
             *nServersPtr = atoi(argv[i]);
             if(*nServersPtr <= 0) {
                 fprintf(stderr, "Number of servers must be greater than 0\n");
@@ -801,7 +818,11 @@ int main(int argc, char **argv)
     numFDs = max(appServerSock, STDIN_FILENO) + 1;
     OS_SetFlags(appServerSock, O_NONBLOCK);
 
+    if (bytesToRead <= 0)
+       WriteStdinEof();
+
     ScheduleIo();
+
     while(!exitStatusSet) {
         /*
         * NULL = wait forever (or at least until there's something