]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug fix: Server transaction stuck in RESPMOD ACL check if no services matched.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 16 Jul 2009 18:40:00 +0000 (12:40 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 16 Jul 2009 18:40:00 +0000 (12:40 -0600)
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.

src/adaptation/AccessCheck.cc
src/adaptation/AccessCheck.h

index 2ecd3bebdb96d2e9720c3f7388b33e9641d45f38..e3350a466b3d4546ce87e96977b77fec1fd315d8 100644 (file)
@@ -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()
index f3923acd54b849d8525b9107a4cab2023612d33c..11f89af5df2b033b3f4de0c8250272b338652914 100644 (file)
@@ -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);
 };