/*
- * $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\"";
/*
- * $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
}
}
+#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)
{
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);