]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessCheck.h
Bug fix: Server transaction stuck in RESPMOD ACL check if no services matched.
[thirdparty/squid.git] / src / adaptation / AccessCheck.h
1 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
2 #define SQUID_ADAPTATION__ACCESS_CHECK_H
3
4 #include "base/AsyncJob.h"
5 #include "adaptation/Elements.h"
6 #include "adaptation/forward.h"
7 #include "adaptation/ServiceFilter.h"
8
9 class HttpRequest;
10 class HttpReply;
11 class ACLFilledChecklist;
12
13 namespace Adaptation
14 {
15
16 class AccessRule;
17
18 // checks adaptation_access rules to find a matching adaptation service
19 class AccessCheck: public virtual AsyncJob
20 {
21 public:
22 typedef void AccessCheckCallback(ServiceGroupPointer group, void *data);
23
24 // use this to start async ACL checks; returns true if started
25 static bool Start(Method method, VectPoint vp, HttpRequest *req,
26 HttpReply *rep, AccessCheckCallback *cb, void *cbdata);
27
28 protected:
29 // use Start to start adaptation checks
30 AccessCheck(const ServiceFilter &aFilter, AccessCheckCallback *, void *);
31 ~AccessCheck();
32
33 private:
34 const ServiceFilter filter;
35 AccessCheckCallback *callback;
36 void *callback_data;
37 ACLFilledChecklist *acl_checklist;
38
39 typedef int Candidate;
40 typedef Vector<Candidate> Candidates;
41 Candidates candidates;
42 Candidate topCandidate() const { return *candidates.begin(); }
43 ServiceGroupPointer topGroup() const; // may return nil
44
45 void callBack(const ServiceGroupPointer &g);
46 bool isCandidate(AccessRule &r);
47
48 public:
49 void checkCandidates();
50 static void AccessCheckCallbackWrapper(int, void*);
51 void noteAnswer(int answer);
52
53 protected:
54 // AsyncJob API
55 virtual void start();
56 virtual bool doneAll() const { return false; } /// not done until mustStop
57
58 void check();
59
60 private:
61 CBDATA_CLASS2(AccessCheck);
62 };
63
64 } // namespace Adaptation
65
66 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */