---------------------
PatchSet 1643 
Date: 2005/09/01 22:55:04
Author: dwsquid
Branch: squid3-icap
Tag: (none) 
Log:
Rearrange leakfinder calls.  Move add/delete to MsgPipe constructors
and destructors.

Members: 
	src/ICAPAnchor.cc:1.1.2.23->1.1.2.24 
	src/MsgPipe.cc:1.1.2.8->1.1.2.9 
	src/MsgPipe.h:1.1.2.6->1.1.2.7 

Index: squid3/src/ICAPAnchor.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPAnchor.cc,v
retrieving revision 1.1.2.23
retrieving revision 1.1.2.24
diff -u -r1.1.2.23 -r1.1.2.24
--- squid3/src/ICAPAnchor.cc	1 Sep 2005 18:36:03 -0000	1.1.2.23
+++ squid3/src/ICAPAnchor.cc	1 Sep 2005 22:55:04 -0000	1.1.2.24
@@ -13,7 +13,7 @@
 
 CBDATA_CLASS_INIT(ICAPAnchor);
 
-LeakFinder *leaky = new LeakFinder;
+LeakFinder *leaky = NULL; // new LeakFinder;
 
 ICAPAnchor::ICAPAnchor(): httpState(NULL), virgin(NULL), adapted(NULL)
 {
@@ -38,7 +38,7 @@
     httpState = cbdataReference(anHttpState);
 
     virgin = new MsgPipe("virgin"); // this is the place to create a refcount ptr
-    leakAdd(virgin.getRaw(), leaky);
+    leakTouch(virgin.getRaw(), leaky);
     virgin->source = this;
     virgin->data = new MsgPipeData;
     virgin->data->cause = requestLink(request);
@@ -47,7 +47,7 @@
     memBufInit(virgin->data->body, ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax);
 
     adapted = new MsgPipe("adapted");
-    leakAdd(adapted.getRaw(), leaky);
+    leakTouch(adapted.getRaw(), leaky);
     adapted->sink = this;
 #if ICAP_ANCHOR_LOOPBACK
 
@@ -79,6 +79,8 @@
 int
 ICAPAnchor::potentialSpaceSize()
 {
+    if (virgin == NULL)
+	return 0;
     leakTouch(virgin.getRaw(), leaky);
     return (int) virgin->data->body->potentialSpaceSize();
 }
@@ -142,6 +144,7 @@
     debug(93,5)("ICAPAnchor::noteSourceProgress() called\n");
     //tell HttpStateData to store a fresh portion of the adapted response
 
+    leakTouch(p, leaky);
     if (p->data->body->hasContent()) {
         httpState->takeAdaptedBody(p->data->body);
     }
@@ -152,6 +155,7 @@
 {
     debug(93,5)("ICAPAnchor::noteSourceFinish() called\n");
     //tell HttpStateData that we expect no more response data
+    leakTouch(p, leaky);
     httpState->doneAdapting();
     stop(notifyNone);
 }
@@ -160,6 +164,7 @@
 void ICAPAnchor::noteSourceAbort(MsgPipe *p)
 {
     debug(93,5)("ICAPAnchor::noteSourceAbort() called\n");
+    leakTouch(p, leaky);
     stop(notifyOwner);
 }
 
@@ -204,13 +209,13 @@
     requestUnlink(virgin->data->cause);
     virgin->data->cause = NULL;
     virgin->data->header = NULL;
-    leakFree(virgin.getRaw(), leaky);
+    leakTouch(virgin.getRaw(), leaky);
     virgin = NULL;	// refcounted
 }
 
 void ICAPAnchor::freeAdapted()
 {
     adapted->data->header = NULL;	// we don't own it
-    leakFree(adapted.getRaw(), leaky);
+    leakTouch(adapted.getRaw(), leaky);
     adapted = NULL;	// refcounted
 }
Index: squid3/src/MsgPipe.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Attic/MsgPipe.cc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- squid3/src/MsgPipe.cc	26 Aug 2005 20:28:41 -0000	1.1.2.8
+++ squid3/src/MsgPipe.cc	1 Sep 2005 22:55:04 -0000	1.1.2.9
@@ -3,6 +3,9 @@
 #include "MsgPipeSource.h"
 #include "MsgPipeSink.h"
 
+#include "LeakFinder.h"
+extern LeakFinder *leaky;
+
 CBDATA_CLASS_INIT(MsgPipe);
 
 // static event callback template
@@ -26,22 +29,37 @@
 
 MsgPipe::MsgPipe(const char *aName): name(aName),
         data(NULL), source(NULL), sink(NULL)
-{}
+{
+	leakAdd(this, leaky);
+}
+
+MsgPipe::~MsgPipe()
+{
+        delete data;
+        delete source;
+        delete sink;
+	leakFree(this, leaky);
+};
 
 void MsgPipe::sendSourceStart()
 {
+    leakTouch(this, leaky);
     debug(99,5)("MsgPipe::sendSourceStart() called\n");
     sendLater("SourceStart", &MsgPipe_sendSourceStart, sink);
 }
 
+
+
 void MsgPipe::sendSourceProgress()
 {
+    leakTouch(this, leaky);
     debug(99,5)("MsgPipe::sendSourceProgress() called\n");
     sendLater("SourceProgress", &MsgPipe_sendSourceProgress, sink);
 }
 
 void MsgPipe::sendSourceFinish()
 {
+    leakTouch(this, leaky);
     debug(99,5)("MsgPipe::sendSourceFinish() called\n");
     sendLater("sendSourceFinish", &MsgPipe_sendSourceFinish, sink);
     source = NULL;
@@ -49,6 +67,7 @@
 
 void MsgPipe::sendSourceAbort()
 {
+    leakTouch(this, leaky);
     debug(99,5)("MsgPipe::sendSourceAbort() called\n");
     sendLater("SourceAbort", &MsgPipe_sendSourceAbort, sink);
     source = NULL;
@@ -57,12 +76,14 @@
 
 void MsgPipe::sendSinkNeed()
 {
+    leakTouch(this, leaky);
     debug(99,5)("MsgPipe::sendSinkNeed() called\n");
     sendLater("SinkNeed", &MsgPipe_sendSinkNeed, source);
 }
 
 void MsgPipe::sendSinkAbort()
 {
+    leakTouch(this, leaky);
     debug(99,5)("MsgPipe::sendSinkAbort() called\n");
     sendLater("SinkAbort", &MsgPipe_sendSinkAbort, source);
     sink = NULL;
@@ -70,12 +91,14 @@
 
 void MsgPipe::sendLater(const char *callName, EVH * handler, MsgPipeEnd *destination)
 {
+    leakTouch(this, leaky);
     if (canSend(destination, callName, true))
         eventAdd(callName, handler, this, 0, true);
 }
 
 bool MsgPipe::canSend(MsgPipeEnd *destination, const char *callName, bool future)
 {
+    leakTouch(this, leaky);
     const bool res = destination != NULL;
     const char *verb = future ?
                        (res ? "will send " : "wont send ") :
Index: squid3/src/MsgPipe.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Attic/MsgPipe.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- squid3/src/MsgPipe.h	31 Aug 2005 20:03:39 -0000	1.1.2.6
+++ squid3/src/MsgPipe.h	1 Sep 2005 22:55:04 -0000	1.1.2.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: MsgPipe.h,v 1.1.2.6 2005/08/31 20:03:39 dwsquid Exp $
+ * $Id: MsgPipe.h,v 1.1.2.7 2005/09/01 22:55:04 dwsquid Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -54,12 +54,7 @@
     typedef RefCount<MsgPipe> Pointer;
 
     MsgPipe(const char *aName = "anonym");
-    ~MsgPipe()
-    {
-        delete data;
-        delete source;
-        delete sink;
-    };
+    ~MsgPipe();
 
     // the pipe source calls these to notify the sink
     void sendSourceStart();
