--------------------- PatchSet 6246 Date: 2007/12/05 04:44:29 Author: rousskov Branch: async-calls Tag: (none) Log: Use async calls when notifying registered clients about service availability. Members: src/ICAP/ICAPServiceRep.cc:1.16.4.3->1.16.4.4 src/ICAP/ICAPServiceRep.h:1.11.4.2->1.11.4.3 Index: squid3/src/ICAP/ICAPServiceRep.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPServiceRep.cc,v retrieving revision 1.16.4.3 retrieving revision 1.16.4.4 diff -u -r1.16.4.3 -r1.16.4.4 --- squid3/src/ICAP/ICAPServiceRep.cc 29 Nov 2007 18:06:11 -0000 1.16.4.3 +++ squid3/src/ICAP/ICAPServiceRep.cc 5 Dec 2007 04:44:29 -0000 1.16.4.4 @@ -293,30 +293,26 @@ while (!theClients.empty()) { Client i = theClients.pop_back(); - us = i.service; // prevent callbacks from destroying us while we loop - - if (cbdataReferenceValid(i.data)) - (*i.callback)(i.data, us); - - cbdataReferenceDone(i.data); + ScheduleCallHere(i.callback); + i.callback = 0; } notifying = false; } -void ICAPServiceRep::callWhenReady(Callback *cb, void *data) +void ICAPServiceRep::callWhenReady(AsyncCall *cb) { - debugs(93,5, HERE << "ICAPService is asked to call " << data << + Must(cb); + + debugs(93,5, HERE << "ICAPService is asked to call " << *cb << " when ready " << status()); - Must(cb); Must(self != NULL); Must(!broken()); // we do not wait for a broken service Client i; - i.service = self; + i.service = self; // TODO: is this really needed? i.callback = cb; - i.data = cbdataReference(data); theClients.push_back(i); if (theOptionsFetcher || notifying) Index: squid3/src/ICAP/ICAPServiceRep.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPServiceRep.h,v retrieving revision 1.11.4.2 retrieving revision 1.11.4.3 diff -u -r1.11.4.2 -r1.11.4.3 --- squid3/src/ICAP/ICAPServiceRep.h 13 Nov 2007 22:32:12 -0000 1.11.4.2 +++ squid3/src/ICAP/ICAPServiceRep.h 5 Dec 2007 04:44:29 -0000 1.11.4.3 @@ -1,6 +1,6 @@ /* - * $Id: ICAPServiceRep.h,v 1.11.4.2 2007/11/13 22:32:12 chtsanti Exp $ + * $Id: ICAPServiceRep.h,v 1.11.4.3 2007/12/05 04:44:29 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -90,8 +90,7 @@ bool broken() const; // see comments above bool up() const; // see comments above - typedef void Callback(void *data, Pointer &service); - void callWhenReady(Callback *cb, void *data); + void callWhenReady(AsyncCall *cb); // the methods below can only be called on an up() service bool wantsUrl(const String &urlPath) const; @@ -131,8 +130,7 @@ struct Client { Pointer service; // one for each client to preserve service - Callback *callback; - void *data; + AsyncCall *callback; }; typedef Vector Clients;