From: serassio <> Date: Sun, 11 Sep 2005 01:31:31 +0000 (+0000) Subject: Bug #1368: assertion failed: store.c:523: "e->store_status == X-Git-Tag: SQUID_3_0_PRE4~640 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=b66315e48c847e5f28ac97fd76d8d585dd64774c;p=thirdparty%2Fsquid.git Bug #1368: assertion failed: store.c:523: "e->store_status == STORE_PENDING" on certain aborted requests Forward port of 2.5 patch. --- diff --git a/src/cache_manager.cc b/src/cache_manager.cc index 2aecaa823e..7ac00de4e8 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.cc,v 1.32 2005/09/10 16:03:52 serassio Exp $ + * $Id: cache_manager.cc,v 1.33 2005/09/10 19:31:31 serassio Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -313,8 +313,7 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry) a = cachemgrFindAction(mgr->action); assert(a != NULL); - if (a->flags.atomic) - storeBuffer(entry); + storeBuffer(entry); { HttpVersion version(1,0); @@ -332,10 +331,10 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry) a->handler(entry); - if (a->flags.atomic) { - storeBufferFlush(entry); + storeBufferFlush(entry); + + if (a->flags.atomic) entry->complete(); - } cachemgrStateFree(mgr); } diff --git a/src/ftp.cc b/src/ftp.cc index 45762f9ce9..d3b7100398 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.365 2005/09/10 16:03:52 serassio Exp $ + * $Id: ftp.cc,v 1.366 2005/09/10 19:31:31 serassio Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -473,7 +473,6 @@ ftpListingStart(FtpStateData * ftpState) char *dirup; int i, j, k; const char *title = ftpState->title_url.buf(); - storeBuffer(e); storeAppendPrintf(e, "\n"); storeAppendPrintf(e, "\n", version_string); @@ -548,7 +547,6 @@ ftpListingStart(FtpStateData * ftpState) storeAppendPrintf(e, "
\n");
     dirup = ftpHtmlifyListEntry("", ftpState);
     storeAppend(e, dirup, strlen(dirup));
-    storeBufferFlush(e);
     ftpState->flags.html_header_sent = 1;
 }
 
@@ -572,7 +570,6 @@ ftpListingFinish(FtpStateData * ftpState)
                       getMyHostname(),
                       visible_appname_string);
     storeAppendPrintf(e, "\n");
-    storeBufferFlush(e);
 }
 
 static const char *Month[] =
@@ -1066,7 +1063,7 @@ ftpParseListing(FtpStateData * ftpState)
     debug(9, 3) ("ftpParseListing: %lu bytes to play with\n", (unsigned long int)len);
     line = (char *)memAllocate(MEM_4K_BUF);
     end++;
-    storeBuffer(e);
+    storeBuffer(e);	/* released when done processing current data payload */
     s = sbuf;
     s += strspn(s, crlf);
 
@@ -1094,7 +1091,6 @@ ftpParseListing(FtpStateData * ftpState)
         storeAppend(e, t, strlen(t));
     }
 
-    storeBufferFlush(e);
     assert(usable <= len);
 
     if (usable < len) {
@@ -1223,6 +1219,8 @@ ftpDataRead(int fd, char *buf, size_t len, comm_err_t errflag, int xerrno, void
             ftpState->data.offset = 0;
         }
 
+        storeBufferFlush(entry);
+
         /* XXX what about Config.Timeout.read? */
         read_sz = ftpState->data.size - ftpState->data.offset;
 
@@ -3023,8 +3021,6 @@ ftpSendReply(FtpStateData * ftpState)
 
     errorAppendEntry(ftpState->entry, err);
 
-    storeBufferFlush(ftpState->entry);
-
     ftpSendQuit(ftpState);
 }
 
@@ -3048,6 +3044,8 @@ ftpAppendSuccessHeader(FtpStateData * ftpState)
 
     EBIT_CLR(e->flags, ENTRY_FWD_HDR_WAIT);
 
+    storeBuffer(e);	/* released when done processing current data payload */
+
     filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.buf();
 
     if (ftpState->flags.isdir) {
@@ -3071,7 +3069,6 @@ ftpAppendSuccessHeader(FtpStateData * ftpState)
         }
     }
 
-    storeBuffer(e);
     reply = httpReplyCreate();
     /* set standard stuff */
 
@@ -3097,8 +3094,6 @@ ftpAppendSuccessHeader(FtpStateData * ftpState)
 
     httpReplySwapOut(reply, e);
 
-    storeBufferFlush(e);
-
     storeTimestampsSet(e);
 
     if (ftpState->flags.authenticated) {
diff --git a/src/gopher.cc b/src/gopher.cc
index 9da8be0d45..f0d0c13371 100644
--- a/src/gopher.cc
+++ b/src/gopher.cc
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.188 2005/09/10 16:03:52 serassio Exp $
+ * $Id: gopher.cc,v 1.189 2005/09/10 19:31:31 serassio Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -856,27 +856,26 @@ gopherSendComplete(int fd, char *buf, size_t size, comm_err_t errflag, int xerrn
      * OK. We successfully reach remote site.  Start MIME typing
      * stuff.  Do it anyway even though request is not HTML type.
      */
+    storeBuffer(entry);
+
     gopherMimeCreate(gopherState);
 
     switch (gopherState->type_id) {
 
     case GOPHER_DIRECTORY:
         /* we got to convert it first */
-        storeBuffer(entry);
         gopherState->conversion = gopher_ds::HTML_DIR;
         gopherState->HTML_header_added = 0;
         break;
 
     case GOPHER_INDEX:
         /* we got to convert it first */
-        storeBuffer(entry);
         gopherState->conversion = gopher_ds::HTML_INDEX_RESULT;
         gopherState->HTML_header_added = 0;
         break;
 
     case GOPHER_CSO:
         /* we got to convert it first */
-        storeBuffer(entry);
         gopherState->conversion = gopher_ds::HTML_CSO_RESULT;
         gopherState->cso_recno = 0;
         gopherState->HTML_header_added = 0;
@@ -884,6 +883,7 @@ gopherSendComplete(int fd, char *buf, size_t size, comm_err_t errflag, int xerrn
 
     default:
         gopherState->conversion = gopher_ds::NORMAL;
+        storeBufferFlush(entry);
     }
 
     /* Schedule read reply. */
diff --git a/src/store.cc b/src/store.cc
index 41282ecb00..47e7f7d7fd 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.578 2005/01/03 16:08:26 robertc Exp $
+ * $Id: store.cc,v 1.579 2005/09/10 19:31:31 serassio Exp $
  *
  * DEBUG: section 20    Storage Manager
  * AUTHOR: Harvest Derived
@@ -1630,8 +1630,10 @@ storeBuffer(StoreEntry * e)
 void
 storeBufferFlush(StoreEntry * e)
 {
-    EBIT_CLR(e->flags, DELAY_SENDING);
-    InvokeHandlers(e);
+    if (EBIT_TEST(e->flags, DELAY_SENDING)) {
+        EBIT_CLR(e->flags, DELAY_SENDING);
+        InvokeHandlers(e);
+    }
 }
 
 ssize_t
diff --git a/src/whois.cc b/src/whois.cc
index 3bb150b200..a3e29bc03d 100644
--- a/src/whois.cc
+++ b/src/whois.cc
@@ -1,6 +1,6 @@
 
 /*
- * $Id: whois.cc,v 1.29 2005/09/10 16:03:52 serassio Exp $
+ * $Id: whois.cc,v 1.30 2005/09/10 19:31:31 serassio Exp $
  *
  * DEBUG: section 75    WHOIS protocol
  * AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -113,8 +113,9 @@ void
 WhoisState::setReplyToOK(StoreEntry *entry)
 {
     HttpReply *reply = httpReplyCreate();
+    storeBuffer(entry);
     HttpVersion version(1, 0);
-    httpReplySetHeaders(reply, version, HTTP_OK, NULL, NULL, 0, 0, -1);
+    httpReplySetHeaders(reply, version, HTTP_OK, "Gatewaying", "text/plain", -1, -1, -2);
     storeEntryReplaceObject (entry, reply);
 }
 
@@ -146,6 +147,8 @@ WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrn
 
         storeAppend(entry, buf, len);
 
+        storeBufferFlush(entry);
+
         do_next_read = 1;
     } else if (flag != COMM_OK || len < 0) {
         debug(50, 2) ("whoisReadReply: FD %d: read failure: %s.\n",