Forwarder.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 16 Cache Manager API */
10 
11 #include "squid.h"
12 #include "AccessLogEntry.h"
13 #include "base/AsyncJobCalls.h"
14 #include "base/TextException.h"
15 #include "comm/Connection.h"
16 #include "CommCalls.h"
17 #include "errorpage.h"
18 #include "globals.h"
19 #include "HttpReply.h"
20 #include "HttpRequest.h"
21 #include "ipc/Port.h"
22 #include "mgr/Forwarder.h"
23 #include "mgr/Request.h"
24 #include "SquidTime.h"
25 #include "Store.h"
26 
28 
30  HttpRequest* aRequest, StoreEntry* anEntry, const AccessLogEntryPointer &anAle):
31  Ipc::Forwarder(new Request(KidIdentifier, 0, aConn, aParams), 10),
32  httpRequest(aRequest), entry(anEntry), conn(aConn), ale(anAle)
33 {
34  debugs(16, 5, HERE << conn);
36  Must(httpRequest != NULL);
37  Must(entry != NULL);
38 
40  entry->lock("Mgr::Forwarder");
41 
42  closer = asyncCall(16, 5, "Mgr::Forwarder::noteCommClosed",
45 }
46 
48 {
50  Must(entry);
51  entry->unlock("Mgr::Forwarder");
54  });
55 }
56 
58 void
60 {
61  if (Comm::IsConnOpen(conn)) {
62  if (closer != NULL) {
64  closer = NULL;
65  }
66  conn->close();
67  }
68  conn = NULL;
70 }
71 
72 void
74 {
75  debugs(16, DBG_CRITICAL, "ERROR: uri " << entry->url() << " exceeds buffer size");
77  mustStop("long URI");
78 }
79 
80 void
82 {
85 }
86 
87 void
88 Mgr::Forwarder::handleException(const std::exception &e)
89 {
93 }
94 
96 void
98 {
99  debugs(16, 5, HERE);
100  conn = NULL; // needed?
101  mustStop("commClosed");
102 }
103 
105 void
107 {
108  debugs(16, 3, HERE);
109  Must(error != NULL);
110  Must(entry != NULL);
111  Must(httpRequest != NULL);
112 
113  entry->buffer();
116  delete error;
117  entry->flush();
118  entry->complete();
119 }
120 
cache manager request
Definition: Request.h:22
virtual void handleException(const std::exception &e)
terminate with an error
Definition: Forwarder.cc:129
virtual void handleTimeout()
Definition: Forwarder.cc:81
AccessLogEntryPointer ale
more transaction details
Definition: Forwarder.h:56
int unlock(const char *context)
Definition: store.cc:463
void mustStop(const char *aReason)
Definition: AsyncJob.cc:69
void error(char *format,...)
virtual void buffer()
Definition: store.cc:1649
Definition: IpcIoFile.h:23
virtual void flush()
Definition: store.cc:1660
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:160
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:69
Forwarder(const Comm::ConnectionPointer &aConn, const ActionParams &aParams, HttpRequest *aRequest, StoreEntry *anEntry, const AccessLogEntryPointer &anAle)
Definition: Forwarder.cc:29
#define DBG_CRITICAL
Definition: Debug.h:45
int conn
the current server connection FD
Definition: Transport.cc:26
time_t expires
Definition: Store.h:214
time_t squid_curtime
Definition: stub_time.cc:17
Cache Manager Action parameters extracted from the user request.
Definition: ActionParams.h:23
#define SWALLOW_EXCEPTIONS(code)
Definition: TextException.h:73
AsyncCall * asyncCall(int aDebugSection, int aDebugLevel, const char *aName, const Dialer &aDialer)
Definition: AsyncCall.h:161
AsyncCall::Pointer closer
comm_close handler for the HTTP connection
Definition: Forwarder.h:55
void complete()
Definition: store.cc:1063
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:26
virtual void handleTimeout()
Definition: Forwarder.cc:122
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:128
const char * url() const
Definition: store.cc:1614
CBDATA_NAMESPACED_CLASS_INIT(Ipc, Forwarder)
virtual void swanSong()
Definition: Forwarder.cc:67
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
Definition: store.cc:1774
virtual void swanSong()
closes our copy of the client HTTP connection socket
Definition: Forwarder.cc:59
HttpRequest * httpRequest
HTTP client request for detailing errors.
Definition: Forwarder.h:52
virtual void handleException(const std::exception &e)
terminate with an error
Definition: Forwarder.cc:88
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:157
virtual void handleError()
Definition: Forwarder.cc:73
int KidIdentifier
virtual ~Forwarder()
Definition: Forwarder.cc:47
void noteCommClosed(const CommCloseCbParams &params)
called when the client socket gets closed by some external force
Definition: Forwarder.cc:97
void HTTPMSGUNLOCK(M *&a)
Definition: Message.h:149
AsyncCall::Pointer comm_add_close_handler(int fd, CLCB *handler, void *data)
Definition: comm.cc:968
HttpReply * BuildHttpReply(void)
Definition: errorpage.cc:1281
void sendError(ErrorState *error)
send error page
Definition: Forwarder.cc:106
void comm_remove_close_handler(int fd, CLCB *handler, void *data)
Definition: comm.cc:995
StoreEntry * entry
Store entry expecting the response.
Definition: Forwarder.h:53
Cache Manager API.
Definition: Action.h:19
#define NULL
Definition: types.h:166
Comm::ConnectionPointer conn
HTTP client connection descriptor.
Definition: Forwarder.h:54
void lock(const char *context)
Definition: store.cc:439

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors