]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
experimental comm_lingering_close()
authorwessels <>
Tue, 12 May 1998 03:34:09 +0000 (03:34 +0000)
committerwessels <>
Tue, 12 May 1998 03:34:09 +0000 (03:34 +0000)
src/client_side.cc
src/comm.cc
src/protos.h

index 48220979c5b85e0896a439a0f28cfb776482a013..05ee35e1cdad45098f9cad97498229437a60e2cc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.302 1998/05/11 20:56:07 rousskov Exp $
+ * $Id: client_side.cc,v 1.303 1998/05/11 21:34:09 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
 
 #include "squid.h"
 
+#if LINGERING_CLOSE
+#define comm_close comm_lingering_close
+#endif
+
 static const char *const crlf = "\r\n";
 static const char *const proxy_auth_challenge =
 "Basic realm=\"Squid proxy-caching web server\"";
index 0d99b2cf8ce2b2b32c4ce6b3079128f106680d2d..47d2a89d12cdacedfffb325e483fc8c797d280b4 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: comm.cc,v 1.253 1998/05/08 22:20:45 wessels Exp $
+ * $Id: comm.cc,v 1.254 1998/05/11 21:34:10 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -619,6 +619,41 @@ commCallCloseHandlers(int fd)
     }
 }
 
+#if LINGERING_CLOSE
+static void
+commLingerClose(int fd, void *unused)
+{
+    LOCAL_ARRAY(char, buf, 1024);
+    int n;
+    n = read(fd, buf, 1024);
+    if (n < 0)
+       debug(5, 3) ("commLingerClose: FD %d read: %s\n", fd, xstrerror());
+    comm_close(fd);
+}
+
+static void
+commLingerTimeout(int fd, void *unused)
+{
+    debug(5, 3) ("commLingerTimeout: FD %d\n", fd);
+    comm_close(fd);
+}
+
+/*
+ * Inspired by apache
+ */
+void
+comm_lingering_close(int fd)
+{
+    if (shutdown(fd, 1) < 0) {
+       comm_close(fd);
+       return;
+    }
+    fd_note(fd, "lingering close");
+    commSetTimeout(fd, 10, commLingerTimeout, NULL);
+    commSetSelect(fd, COMM_SELECT_READ, commLingerClose, NULL, 0);
+}
+#endif
+
 void
 comm_close(int fd)
 {
index 2e661f298aefebfa032646a3f38bbdd819e2c28b..980fe1143886a91691607b3af7a6a7304da5bcac 100644 (file)
@@ -96,6 +96,9 @@ extern int commSetNonBlocking(int fd);
 extern void commSetCloseOnExec(int fd);
 extern int comm_accept(int fd, struct sockaddr_in *, struct sockaddr_in *);
 extern void comm_close(int fd);
+#if LINGERING_CLOSE
+extern void comm_lingering_close(int fd);
+#endif
 extern void commConnectStart(int fd, const char *, u_short, CNCB *, void *);
 extern int comm_connect_addr(int sock, const struct sockaddr_in *);
 extern int comm_init(void);