]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Service.cc
5cba552a0ec6ab43663e588f35224647d9fda7b1
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 93 Adaptation */
12 #include "adaptation/Service.h"
13 #include "adaptation/ServiceFilter.h"
14 #include "HttpRequest.h"
16 Adaptation::Service::Service(const ServiceConfigPointer
&aConfig
): theConfig(aConfig
)
18 Must(theConfig
!= NULL
);
19 debugs(93,3, HERE
<< "creating adaptation service " << cfg().key
);
22 Adaptation::Service::~Service()
26 Adaptation::Service::finalize()
30 bool Adaptation::Service::broken() const
32 return probed() && !up();
36 Adaptation::Service::wants(const ServiceFilter
&filter
) const
38 if (cfg().method
!= filter
.method
)
41 if (cfg().point
!= filter
.point
)
44 // sending a message to a broken service is likely to cause errors
45 if (cfg().bypass
&& broken())
49 // Sending a message to a service that does not want it is useless.
50 // note that we cannot check wantsUrl for service that is not "up"
51 // note that even essential services are skipped on unwanted URLs!
52 return wantsUrl(filter
.request
->url
.path());
55 // The service is down and is either not bypassable or not probed due
56 // to the bypass && broken() test above. Thus, we want to use it!
60 Adaptation::Services
&
61 Adaptation::AllServices()
63 static Services
*TheServices
= new Services
;
67 Adaptation::ServicePointer
68 Adaptation::FindService(const Service::Id
& key
)
70 typedef Services::iterator SI
;
71 for (SI i
= AllServices().begin(); i
!= AllServices().end(); ++i
) {
72 if ((*i
)->cfg().key
== key
)
78 void Adaptation::DetachServices()
80 while (!AllServices().empty()) {
81 AllServices().back()->detach();
82 AllServices().pop_back();