]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
errorpage.c: clear ENTRY_FWD_HDR_WAIT after creating an error page,
authorwessels <>
Tue, 19 Jan 1999 12:24:47 +0000 (12:24 +0000)
committerwessels <>
Tue, 19 Jan 1999 12:24:47 +0000 (12:24 +0000)
     before calling storeComplete

forward.c: break some calling loops for things like failed DNS lookups.
   added FwdState->flags.dont_retry

   assert that ENTRY_FWD_HDR_WAIT is clear when we free
   the FwdState

   added loop detector to fwdConnectDone

src/errorpage.cc
src/forward.cc
src/structs.h

index 3b1d5cf18c01ee5b315cd3629b3ee0032153d191..bd276d4eef7c27baad784f9ece3ca17b0289154c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.146 1999/01/12 16:40:35 wessels Exp $
+ * $Id: errorpage.cc,v 1.147 1999/01/19 05:24:47 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -297,6 +297,7 @@ errorAppendEntry(StoreEntry * entry, ErrorState * err)
     httpReplyDestroy(rep);
     mem->reply->sline.status = err->http_status;
     mem->reply->content_length = -1;
+    EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
     storeBufferFlush(entry);
     storeComplete(entry);
     storeNegativeCache(entry);
index b513e095f68fcdeff453d00dc772cc2663b9da04..c4991c089c272dbb1065a82498c9e394efc4904c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.47 1999/01/19 02:24:24 wessels Exp $
+ * $Id: forward.cc,v 1.48 1999/01/19 05:24:48 wessels Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -38,7 +38,7 @@
 
 static PSC fwdStartComplete;
 static void fwdDispatch(FwdState *);
-static void fwdConnectStart(FwdState * fwdState);
+static void fwdConnectStart(void *);   /* should be same as EVH */
 static void fwdStateFree(FwdState * fwdState);
 static PF fwdConnectTimeout;
 static PF fwdServerClosed;
@@ -86,6 +86,7 @@ fwdStateFree(FwdState * fwdState)
            errorAppendEntry(e, fwdState->err);
        }
     }
+    assert(!EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT));
     fwdServersFree(&fwdState->servers);
     requestUnlink(fwdState->request);
     fwdState->request = NULL;
@@ -114,6 +115,8 @@ fwdCheckRetry(FwdState * fwdState)
        return 0;
     if (squid_curtime - fwdState->start > 120)
        return 0;
+    if (fwdState->flags.dont_retry)
+       return 0;
     if (pumpMethod(fwdState->request->method))
        if (0 == pumpRestart(fwdState->request))
            return 0;
@@ -131,7 +134,8 @@ fwdServerClosed(int fd, void *data)
        debug(17, 3) ("fwdServerClosed: re-forwarding (%d tries, %d secs)\n",
            fwdState->n_tries,
            (int) (squid_curtime - fwdState->start));
-       fwdConnectStart(fwdState);
+       /* use eventAdd to break potential call sequence loops */
+       eventAdd("fwdConnectStart", fwdConnectStart, fwdState, 0.0, 1);
     } else {
        fwdStateFree(fwdState);
     }
@@ -144,8 +148,11 @@ fwdConnectDone(int server_fd, int status, void *data)
     FwdServer *fs = fwdState->servers;
     ErrorState *err;
     request_t *request = fwdState->request;
+    static int loop_detect = 0;
+    assert(loop_detect++ == 0);
     assert(fwdState->server_fd == server_fd);
     if (status == COMM_ERR_DNS) {
+       fwdState->flags.dont_retry = 1;
        debug(17, 4) ("fwdConnectDone: Unknown host: %s\n",
            request->host);
        err = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE);
@@ -174,6 +181,7 @@ fwdConnectDone(int server_fd, int status, void *data)
        fd_table[server_fd].uses++;
        fwdDispatch(fwdState);
     }
+    loop_detect--;
 }
 
 static void
@@ -194,8 +202,9 @@ fwdConnectTimeout(int fd, void *data)
 }
 
 static void
-fwdConnectStart(FwdState * fwdState)
+fwdConnectStart(void *data)
 {
+    FwdState * fwdState = data;
     const char *url = storeUrl(fwdState->entry);
     int fd;
     ErrorState *err;
index 171cfedf60213c0de63ff757652b563ebb48f178..11d85329e3c7a6a695da3efa3f8124009b3567e9 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: structs.h,v 1.262 1999/01/19 02:24:34 wessels Exp $
+ * $Id: structs.h,v 1.263 1999/01/19 05:24:49 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1596,6 +1596,9 @@ struct _FwdState {
     ErrorState *err;
     time_t start;
     int n_tries;
+    struct {
+       unsigned int dont_retry:1;
+    } flags;
 };
 
 #if USE_HTCP