]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ipc/Forwarder.h
Docs: Add man(8) page for helper-mux tool
[thirdparty/squid.git] / src / ipc / Forwarder.h
CommitLineData
51ea0904 1/*
bbc27441 2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
51ea0904 3 *
bbc27441
AJ
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.
51ea0904
CT
7 */
8
bbc27441
AJ
9/* DEBUG: section 54 Interprocess Communication */
10
51ea0904
CT
11#ifndef SQUID_IPC_FORWARDER_H
12#define SQUID_IPC_FORWARDER_H
13
14#include "base/AsyncJob.h"
c6983ec7 15#include "cbdata.h"
51ea0904 16#include "ipc/Request.h"
c6983ec7
FC
17#include "mgr/ActionParams.h"
18
51ea0904
CT
19#include <map>
20
51ea0904
CT
21namespace Ipc
22{
23
24/** Forwards a worker request to coordinator.
25 * Waits for an ACK from Coordinator
26 * Send the data unit with an error response if forwarding fails.
27 */
28class Forwarder: public AsyncJob
29{
30public:
31 Forwarder(Request::Pointer aRequest, double aTimeout);
32 virtual ~Forwarder();
33
34 /// finds and calls the right Forwarder upon Coordinator's response
35 static void HandleRemoteAck(unsigned int requestId);
36
37 /* has-to-be-public AsyncJob API */
38 virtual void callException(const std::exception& e);
39
40protected:
41 /* AsyncJob API */
42 virtual void start();
43 virtual void swanSong();
44 virtual bool doneAll() const;
45
46 virtual void cleanup(); ///< perform cleanup actions
47 virtual void handleError();
48 virtual void handleTimeout();
49 virtual void handleException(const std::exception& e);
50 virtual void handleRemoteAck();
51
52private:
53 static void RequestTimedOut(void* param);
54 void requestTimedOut();
55 void removeTimeoutEvent();
56 static AsyncCall::Pointer DequeueRequest(unsigned int requestId);
57
58protected:
59 Request::Pointer request;
60 const double timeout; ///< response wait timeout in seconds
61
62 /// maps request->id to Forwarder::handleRemoteAck callback
63 typedef std::map<unsigned int, AsyncCall::Pointer> RequestsMap;
64 static RequestsMap TheRequestsMap; ///< pending Coordinator requests
65
66 static unsigned int LastRequestId; ///< last requestId used
67
68 CBDATA_CLASS2(Forwarder);
69};
70
71} // namespace Ipc
72
73#endif /* SQUID_IPC_FORWARDER_H */