]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1368: assertion failed: store.c:523: "e->store_status ==
authorserassio <>
Sun, 11 Sep 2005 01:31:31 +0000 (01:31 +0000)
committerserassio <>
Sun, 11 Sep 2005 01:31:31 +0000 (01:31 +0000)
STORE_PENDING" on certain aborted requests

Forward port of 2.5 patch.

src/cache_manager.cc
src/ftp.cc
src/gopher.cc
src/store.cc
src/whois.cc

index 2aecaa823efea8403044afcc7bcd71772bb99508..7ac00de4e8cedfb83935dd7fabe6be60f2e0a122 100644 (file)
@@ -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);
 }
index 45762f9ce94027b84ddeb44079f77ba3372fa757..d3b71003988fa2911c0ff9cabfc7b41bbd044a52 100644 (file)
@@ -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, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
     storeAppendPrintf(e, "<!-- HTML listing generated by Squid %s -->\n",
                       version_string);
@@ -548,7 +547,6 @@ ftpListingStart(FtpStateData * ftpState)
     storeAppendPrintf(e, "<PRE>\n");
     dirup = ftpHtmlifyListEntry("<internal-dirup>", 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, "</ADDRESS></BODY></HTML>\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) {
index 9da8be0d45a27c801a0a6d113d53d4839222dbb3..f0d0c13371ae7026eb35a4174b6d659f7dd3c118 100644 (file)
@@ -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. */
index 41282ecb00a0941f9e404224ddf808779695970b..47e7f7d7fd58f36ca1139c924bdbcf31beb522d3 100644 (file)
@@ -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
index 3bb150b200aeef556d10eb69f23b31f43d9956d8..a3e29bc03d106615fe5e97fb015b02915a0f4930 100644 (file)
@@ -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",