]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
This patch was posted to squid-users some time ago. It allows the admin
authorwessels <>
Mon, 1 Apr 2002 13:02:15 +0000 (13:02 +0000)
committerwessels <>
Mon, 1 Apr 2002 13:02:15 +0000 (13:02 +0000)
to make Squid send TCP resets for certain error pages.

src/client_side.cc
src/comm.cc
src/errorpage.cc
src/protos.h
src/structs.h

index 52ba2f1d90b594a5bc595297a8c8768fa6beb795..acdd173323ea0c2384f810b2a0feea46db887a36 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.566 2002/04/01 05:59:50 wessels Exp $
+ * $Id: client_side.cc,v 1.567 2002/04/01 06:02:15 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1531,6 +1531,9 @@ clientSendMoreData(void *data, char *retbuf, ssize_t retsize)
        /* there is another object in progress, defer this one */
        debug(33, 2) ("clientSendMoreData: Deferring %s\n", storeUrl(entry));
        return;
+    } else if (http->request->flags.reset_tcp) {
+       comm_reset_close(fd);
+       return;
     } else if (entry && EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
        /* call clientWriteComplete so the client socket gets closed */
        clientWriteComplete(fd, NULL, 0, COMM_OK, http);
index 31fbe9e3b67812415145c58a0baee874a7c9a575..4cda13a42b86f6466f7d16ffe80e47c647139d8b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.327 2002/04/01 05:59:50 wessels Exp $
+ * $Id: comm.cc,v 1.328 2002/04/01 06:02:15 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -614,6 +614,21 @@ comm_lingering_close(int fd)
 }
 #endif
 
+/*
+ * enable linger with time of 0 so that when the socket is
+ * closed, TCP generates a RESET
+ */
+void
+comm_reset_close(int fd)
+{
+    struct linger L;
+    L.l_onoff = 1;
+    L.l_linger = 0;
+    if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0)
+       debug(50, 0) ("commResetTCPClose: FD %d: %s\n", fd, xstrerror());
+    comm_close(fd);
+}
+
 void
 comm_close(int fd)
 {
index 641439aa5b2cd247e0bf898fa70badd4f15db12d..757f43ab2ccb92879c967878611aa98349af3203 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.168 2002/01/01 21:24:25 hno Exp $
+ * $Id: errorpage.cc,v 1.169 2002/04/01 06:02:15 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -274,6 +274,12 @@ errorAppendEntry(StoreEntry * entry, ErrorState * err)
        errorStateFree(err);
        return;
     }
+    if (0 == strncmp(error_text[err->page_id], "reset", 5)) {
+       if (err->request) {
+           debug(0, 0) ("RSTing this reply\n");
+           err->request->flags.reset_tcp = 1;
+       }
+    }
     storeLockObject(entry);
     storeBuffer(entry);
     rep = errorBuildReply(err);
index 3ee2c37968f900eaacb36e11b791add6447e9b1e..564b496d750c4a2227b831d2174fef10ce4150b6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.429 2002/04/01 05:59:50 wessels Exp $
+ * $Id: protos.h,v 1.430 2002/04/01 06:02:16 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -148,6 +148,7 @@ extern int commUnsetNonBlocking(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);
+extern void comm_reset_close(int fd);
 #if LINGERING_CLOSE
 extern void comm_lingering_close(int fd);
 #endif
index 396e886feb88501ad4cb4f1d09ac91019111da67..6d6042716e564a4bafa9509729c50dbf017b4d53 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.411 2002/04/01 05:59:50 wessels Exp $
+ * $Id: structs.h,v 1.412 2002/04/01 06:02:16 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -1607,6 +1607,7 @@ struct _request_flags {
     unsigned int accelerated:1;
     unsigned int internal:1;
     unsigned int body_sent:1;
+    unsigned int reset_tcp:1;
 };
 
 struct _link_list {