]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix bug 1642: FTP assertion/blank page on authentication error
authoradrian <>
Sat, 2 Sep 2006 16:03:20 +0000 (16:03 +0000)
committeradrian <>
Sat, 2 Sep 2006 16:03:20 +0000 (16:03 +0000)
http://www.squid-cache.org/bugs/show_bug.cgi?id=1642

* break out the connection completion code away from the FwdState destructor
* place into ::completed
* Add a flag which goes true when completed has been called; add some
  debugging to indicate (loudly!) if this condition is kicked off
* call ::completed via ::complete if the connection isn't being forwarded;
  mirroring the fwdStateFree() semantics in fwdComplete() from squid-2

src/forward.cc
src/forward.h
src/ftp.cc

index b00cf383bca3dc42d6437e06f550df8623715881..0d0582185b458152e12b747239b8c1380d5203e2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.149 2006/08/25 15:22:34 serassio Exp $
+ * $Id: forward.cc,v 1.150 2006/09/02 10:03:20 adrian Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -105,9 +105,15 @@ FwdState::FwdState(int fd, StoreEntry * e, HttpRequest * r)
     storeRegisterAbort(e, FwdState::abort, this);
 }
 
-FwdState::~FwdState()
+void
+FwdState::completed()
 {
-    debugs(17, 3, HERE << "FwdState destructor starting");
+       if (flags.forward_completed == 1) {
+               debugs(17, 1, HERE << "FwdState::completed called on a completed request! Bad!");
+               return;
+       }
+       flags.forward_completed = 1;
+
 #if URL_CHECKSUM_DEBUG
 
     entry->mem_obj->checkUrlChecksum();
@@ -132,6 +138,14 @@ FwdState::~FwdState()
     if (storePendingNClients(entry) > 0)
         assert(!EBIT_TEST(entry->flags, ENTRY_FWD_HDR_WAIT));
 
+}
+
+FwdState::~FwdState()
+{
+    debugs(17, 3, HERE << "FwdState destructor starting");
+    if (! flags.forward_completed)
+           completed();
+
     serversFree(&servers);
 
     HTTPMSGUNLOCK(request);
@@ -153,7 +167,6 @@ FwdState::~FwdState()
         debug(17, 3) ("fwdStateFree: closing FD %d\n", fd);
         comm_close(fd);
     }
-
     debugs(17, 3, HERE << "FwdState destructor done");
 }
 
@@ -233,6 +246,7 @@ FwdState::fwdStart(int client_fd, StoreEntry *entry, HttpRequest *request)
 
     default:
         FwdState *fwd = new FwdState(client_fd, entry, request);
+       fwd->flags.forward_completed = 0;
         peerSelect(request, entry, fwdStartCompleteWrapper, fwd);
         return;
     }
@@ -313,7 +327,7 @@ FwdState::complete()
         debug(17, 3) ("fwdComplete: not re-forwarding status %d\n",
                       entry->getReply()->sline.status);
         EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
-        entry->complete();
+       completed();
     }
 }
 
index 9c2f416fbb58861c50c4033cdc62c4012e3c4d8b..16451ec041582f891aab7ef75e180b868876ce41 100644 (file)
@@ -58,6 +58,7 @@ public:
 
 private:
     static void logReplyStatus(int tries, http_status status);
+    void completed();
 
 #if WIP_FWD_LOG
 
@@ -94,6 +95,8 @@ unsigned int dont_retry:
 
 unsigned int ftp_pasv_failed:
         1;
+
+unsigned int forward_completed:1;
     }
 
     flags;
index a0781fe500e16b149877e9f221d6aac337fa014e..bfc8e1b0c452e8a5375cb809cc0836691db7c361 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.402 2006/09/02 03:35:52 adrian Exp $
+ * $Id: ftp.cc,v 1.403 2006/09/02 10:03:20 adrian Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -443,7 +443,6 @@ FtpStateData::~FtpStateData()
     safe_free(filepath);
 
     safe_free(data.host);
-
     fwd = NULL;        // refcounted
 }