From: Alex Rousskov Date: Thu, 16 Jul 2009 18:40:00 +0000 (-0600) Subject: Bug fix: Server transaction stuck in RESPMOD ACL check if no services matched. X-Git-Tag: SQUID_3_2_0_1~875 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd5d71724134d630e20438bcd12db0c585587b40;p=thirdparty%2Fsquid.git Bug fix: Server transaction stuck in RESPMOD ACL check if no services matched. AccessCheck job code assumed it was running asynchronously. However, the job was started synchronously. If the access check result was available immediately, without any async ACL checks, then AccessCheck would call the callback immediately, before returning from AccessCheck::Start. The server-side code would then get confused because it uses the AccessCheck::Start return value to change its state, and that value was stale when AccessCheck::Start returned _after_ calling the callback. We now start AccessCheck job properly, via AsyncStart. All checks are now performed in a detached async state. TODO: There are other jobs that are not started asynchronously. Fix. --- diff --git a/src/adaptation/AccessCheck.cc b/src/adaptation/AccessCheck.cc index 2ecd3bebdb..e3350a466b 100644 --- a/src/adaptation/AccessCheck.cc +++ b/src/adaptation/AccessCheck.cc @@ -23,10 +23,8 @@ Adaptation::AccessCheck::Start(Method method, VectPoint vp, if (Config::Enabled) { // the new check will call the callback and delete self, eventually - AccessCheck *check = new AccessCheck( - ServiceFilter(method, vp, req, rep), cb, cbdata); - check->check(); - return true; + return AsyncStart(new AccessCheck( + ServiceFilter(method, vp, req, rep), cb, cbdata)); } debugs(83, 3, HERE << "adaptation off, skipping"); @@ -62,6 +60,12 @@ Adaptation::AccessCheck::~AccessCheck() cbdataReferenceDone(callback_data); } +void +Adaptation::AccessCheck::start() { + AsyncJob::start(); + check(); +} + /// Walk the access rules list to find rules with applicable service groups void Adaptation::AccessCheck::check() diff --git a/src/adaptation/AccessCheck.h b/src/adaptation/AccessCheck.h index f3923acd54..11f89af5df 100644 --- a/src/adaptation/AccessCheck.h +++ b/src/adaptation/AccessCheck.h @@ -46,14 +46,17 @@ private: bool isCandidate(AccessRule &r); public: - void check(); void checkCandidates(); static void AccessCheckCallbackWrapper(int, void*); void noteAnswer(int answer); +protected: // AsyncJob API + virtual void start(); virtual bool doneAll() const { return false; } /// not done until mustStop + void check(); + private: CBDATA_CLASS2(AccessCheck); };