]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Tue, 31 Aug 2010 01:43:31 +0000 (19:43 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Tue, 31 Aug 2010 01:43:31 +0000 (19:43 -0600)
Made eCAP compile again after CbcPointer<> changes.

Old eCAP code tried to call stillProducing(this) and stillConsuming(this)
methods from a const status() method. Doing so produces compiler errors
because stillProducing() and stillConsuming() do not accept pointers to
constant jobs.

CBDATA_CLASSes and, hence, CbcPointer<>, do not support const-correctness
well: In order to create/destroy a cbdata-based smart pointer, one has to
lock/unlock cbdata, which requires modifying the object. Thus, the smart
pointer cannot point to a truly constant object. The core of the problem is
that CBDATA_CLASSes keep cbdata and object data together. When all raw/dumb
CBDATA_CLASS pointers are gone, we can separate the two "datas" and solve the
const-correctness problem for good. The "separate-datas" design would even be
consistent with the original cbdata design which we often violate, IMO.

There are other workarounds. We could declare toCbdata() constant, for
example. However, that would essentially disable checks where a
cbdata-protected object is being destroyed despite the caller's intent to keep
the object constant. This change is not as general but is also much less
intrusive.

Also; handle assignment to self correctly.

src/adaptation/ecap/XactionRep.cc
src/base/CbcPointer.h

index b0f657e1ad68a68bc45f08d6f6ee8ff19887e381..cb9bb7ede7680e4783840f5d6fd744bef25f1669 100644 (file)
@@ -430,9 +430,8 @@ Adaptation::Ecap::XactionRep::status() const
         const BodyPipePointer &vp = theVirginRep.raw().body_pipe;
         if (!canAccessVb)
             buf.append("x", 1);
-        if (vp != NULL && vp->stillConsuming(this)) {
+        if (vp != NULL) { // XXX: but may not be stillConsuming()
             buf.append("Vb", 2);
-            buf.append(vp->status(), strlen(vp->status())); // XXX
         } else
             buf.append("V.", 2);
     }
@@ -441,9 +440,8 @@ Adaptation::Ecap::XactionRep::status() const
         MessageRep *rep = dynamic_cast<MessageRep*>(theAnswerRep.get());
         Must(rep);
         const BodyPipePointer &ap = rep->raw().body_pipe;
-        if (ap != NULL && ap->stillProducing(this)) {
+        if (ap != NULL) { // XXX: but may not be stillProducing()
             buf.append(" Ab", 3);
-            buf.append(ap->status(), strlen(ap->status())); // XXX
         } else
             buf.append(" A.", 3);
     }
index 97067f89d116a8ac42b0a158fd666223caa517f4..c3fd6a89204e8783e376ae2f7e3a88314e60727b 100644 (file)
@@ -48,10 +48,12 @@ public:
     /// support assigning a child cbc pointer to a parent cbc pointer
     template <typename Other>
     CbcPointer &operator =(const CbcPointer<Other> &o) {
+        if (this != &o) { // assignment to self
         clear();
         cbc = o.raw(); // so that set() is accurate
         if (o.valid())
             lock = cbdataReference(o->toCbdata());
+        }
         return *this;
     }
 
@@ -101,10 +103,12 @@ CbcPointer<Cbc>::~CbcPointer()
 template<class Cbc>
 CbcPointer<Cbc> &CbcPointer<Cbc>::operator =(const CbcPointer &d)
 {
+    if (this != &d) { // assignment to self
     clear();
     cbc = d.cbc;
     if (d.lock && cbdataReferenceValid(d.lock))
         lock = cbdataReference(d.lock);
+    }
     return *this;
 }