add attach()/detach() support
[catagits/fcgi2.git] / libfcgi / os_unix.c
index 73e6a7f..6d7dc53 100755 (executable)
@@ -17,7 +17,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: os_unix.c,v 1.37 2002/03/05 19:14:49 robs Exp $";
+static const char rcsid[] = "$Id: os_unix.c,v 1.38 2003/06/22 00:16:43 robs Exp $";
 #endif /* not lint */
 
 #include "fcgi_config.h"
@@ -719,7 +719,7 @@ int OS_AsyncWrite(int fd, int offset, void *buf, int len,
  *
  *--------------------------------------------------------------
  */
-int OS_Close(int fd)
+int OS_Close(int fd, int shutdown_ok)
 {
     if (fd == -1)
         return 0;
@@ -753,23 +753,26 @@ int OS_Close(int fd)
      * cause the client to discard potentially useful response data.
      */
 
-    if (shutdown(fd, 1) == 0)
+    if (shutdown_ok)
     {
-        struct timeval tv;
-        fd_set rfds;
-        int rv;
-        char trash[1024];
-
-        FD_ZERO(&rfds);
-
-        do 
+        if (shutdown(fd, 1) == 0)
         {
-            FD_SET(fd, &rfds);
-            tv.tv_sec = 2;
-            tv.tv_usec = 0;
-            rv = select(fd + 1, &rfds, NULL, NULL, &tv);
+            struct timeval tv;
+            fd_set rfds;
+            int rv;
+            char trash[1024];
+
+            FD_ZERO(&rfds);
+
+            do 
+            {
+                FD_SET(fd, &rfds);
+                tv.tv_sec = 2;
+                tv.tv_usec = 0;
+                rv = select(fd + 1, &rfds, NULL, NULL, &tv);
+            }
+            while (rv > 0 && read(fd, trash, sizeof(trash)) > 0);
         }
-        while (rv > 0 && read(fd, trash, sizeof(trash)) > 0);
     }
 
     return close(fd);
@@ -1229,9 +1232,9 @@ int OS_Accept(int listen_sock, int fail_on_intr, const char *webServerAddrs)
  *
  *----------------------------------------------------------------------
  */
-int OS_IpcClose(int ipcFd)
+int OS_IpcClose(int ipcFd, int shutdown)
 {
-    return OS_Close(ipcFd);
+    return OS_Close(ipcFd, shutdown);
 }
 
 /*