On Sun, Feb 15, 2004, Adrian Chadd wrote: > > Hi, > > Here's a little patch which does three things:
.. needs to do four: 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 06:11:13 -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,11 +1345,9 @@ 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); } @@ -1358,7 +1356,7 @@ { ConnectStateData *cs = (ConnectStateData *)data; debug(5, 3) ("commConnectFree: FD %d\n", fd); - cbdataReferenceDone(cs->callback.data); + cs->callback = CallBack<CNCB>(); safe_free(cs->host); delete cs; } .. the last bit is in commConnectFree() - I guess I havent hit the failed connect part yet but even if it did we shouldn't be poking in cs->callback.data. Gah. Is there anything wrong with these patches? I'd like to commit it and start working on finding other CallBack/cbdata macro bugs. At least I'm not leaking memory anymore.. Adrian