fwdState patch + fix ideas?

From: Adrian Chadd <adrian@dont-contact.us>
Date: Sun, 15 Feb 2004 22:59:10 -0700

Hi,

Here's a little patch which does three things:

* breaks out the if (cbdataReferenceValid(data)) check
  which is using CallBack.data into a seperate method;
* deletes the extra reference/dereference which the CallBack
  code is meant to be doing for us; and
* uses the two above in the offending code.

Now, I'm going to have a look at the other uses of CallBack
and see if I can do something similar.

I'm also going to have a look at "fixing" the cbdataReferenceDone()
macro stuff, probably by duplicating it into a new macro, since
it will be blowing away pointers inside CallBack. Hopefully its
just NULLing pointers we're going to need to NULL anyway but I
really dislike the idea of "magic" behaviour in classes due
to this Macro code. Lord knows the bug took long enough to track.

Comments/suggestions?

Adrian

patch:

adrian@mierda:~/work/squid/squid3/src$ more /tmp/diff
Index: comm.cc
===================================================================
RCS file: /server/cvs-server/squid/squid3/src/comm.cc,v
retrieving revision 1.391
diff -u -r1.391 comm.cc
--- comm.cc 20 Oct 2003 12:33:01 -0000 1.391
+++ comm.cc 16 Feb 2004 05:55:30 -0000
@@ -1302,7 +1302,7 @@
     cs->fd = fd;
     cs->host = xstrdup(host);
     cs->port = port;
- cs->callback = CallBack<CNCB>(callback,cbdataReference(data));
+ cs->callback = CallBack<CNCB>(callback, data);
     comm_add_close_handler(fd, commConnectFree, cs);
     cs->locks++;
     ipcache_nbgethostbyname(host, commConnectDnsHandle, cs);
@@ -1345,10 +1345,8 @@
     callback = CallBack<CNCB>();
     commSetTimeout(fd, -1, NULL, NULL);

- if (cbdataReferenceValid(aCallback.data))
+ if (aCallback.dataValid())
         aCallback.handler(fd, status, xerrno, aCallback.data);
-
- cbdataReferenceDone(aCallback.data);

     commConnectFree(fd, this);
 }
Index: CommRead.h
===================================================================
RCS file: /server/cvs-server/squid/squid3/src/CommRead.h,v
retrieving revision 1.5
diff -u -r1.5 CommRead.h
--- CommRead.h 10 Jul 2003 09:37:56 -0000 1.5
+++ CommRead.h 16 Feb 2004 05:55:30 -0000
@@ -79,6 +79,10 @@
         return *this;
     }

+ bool dataValid()
+ {
+ return cbdataReferenceValid(data);
+ }

     bool operator == (CallBack const &rhs) { return handler==rhs.handler && data==rhs.data;}
Received on Sun Feb 15 2004 - 22:59:12 MST

This archive was generated by hypermail pre-2.1.9 : Mon Mar 01 2004 - 12:00:04 MST