Service.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 /* DEBUG: section 93 Adaptation */
10 
11 #include "squid.h"
12 #include "adaptation/Service.h"
14 #include "HttpRequest.h"
15 
16 Adaptation::Service::Service(const ServiceConfigPointer &aConfig): theConfig(aConfig)
17 {
18  Must(theConfig != NULL);
19  debugs(93,3, HERE << "creating adaptation service " << cfg().key);
20 }
21 
23 {}
24 
25 void
27 {
28 }
29 
31 {
32  return probed() && !up();
33 }
34 
35 bool
37 {
38  if (cfg().method != filter.method)
39  return false;
40 
41  if (cfg().point != filter.point)
42  return false;
43 
44  // sending a message to a broken service is likely to cause errors
45  if (cfg().bypass && broken())
46  return false;
47 
48  if (up()) {
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());
53  }
54 
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!
57  return true;
58 }
59 
62 {
63  static Services *TheServices = new Services;
64  return *TheServices;
65 }
66 
69 {
70  typedef Services::iterator SI;
71  for (SI i = AllServices().begin(); i != AllServices().end(); ++i) {
72  if ((*i)->cfg().key == key)
73  return *i;
74  }
75  return NULL;
76 }
77 
79 {
80  while (!AllServices().empty()) {
81  AllServices().back()->detach();
82  AllServices().pop_back();
83  }
84 }
85 
std::vector< Adaptation::ServicePointer > Services
Definition: Service.h:70
bool wants(const ServiceFilter &filter) const
Definition: Service.cc:36
virtual ~Service()
Definition: Service.cc:22
int i
Definition: membanger.c:49
Method method
adaptation direction
Definition: ServiceFilter.h:32
const ServiceConfig & cfg() const
Definition: Service.h:51
VectPoint point
adaptation location
Definition: ServiceFilter.h:33
ServicePointer FindService(const Service::Id &key)
Definition: Service.cc:68
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
HttpRequest * request
HTTP request being adapted or cause; may be nil.
Definition: ServiceFilter.h:34
URL url
the request URI
Definition: HttpRequest.h:103
void path(const char *p)
Definition: URL.h:77
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:147
#define Must(cond)
Definition: TextException.h:89
Services & AllServices()
Definition: Service.cc:61
information used to search for adaptation services
Definition: ServiceFilter.h:22
virtual void finalize()
Definition: Service.cc:26
ServiceConfigPointer theConfig
Definition: Service.h:65
size_t HttpReply *STUB StoreEntry const KeyScope scope const HttpRequestMethod & method
Definition: stub_store.cc:126
void const cache_key * key
Service(const ServiceConfigPointer &aConfig)
Definition: Service.cc:16
virtual bool broken() const
Definition: Service.cc:30
static AdapterServices TheServices
all loaded services
Definition: ServiceRep.cc:31
#define NULL
Definition: types.h:166
void DetachServices()
detach all adaptation services from current configuration
Definition: Service.cc:78

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors