]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/Request.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / Request.cc
1 /*
2 * $Id$
3 *
4 * DEBUG: section 16 Cache Manager API
5 *
6 */
7
8 #include "squid.h"
9 #include "base/TextException.h"
10 #include "comm/Connection.h"
11 #include "ipc/Messages.h"
12 #include "ipc/TypedMsgHdr.h"
13 #include "mgr/ActionParams.h"
14 #include "mgr/Request.h"
15
16 Mgr::Request::Request(int aRequestorId, unsigned int aRequestId, const Comm::ConnectionPointer &aConn,
17 const ActionParams &aParams):
18 Ipc::Request(aRequestorId, aRequestId),
19 conn(aConn),
20 params(aParams)
21 {
22 Must(requestorId > 0);
23 }
24
25 Mgr::Request::Request(const Request& request):
26 Ipc::Request(request.requestorId, request.requestId),
27 conn(request.conn), params(request.params)
28 {
29 }
30
31 Mgr::Request::Request(const Ipc::TypedMsgHdr& msg):
32 Ipc::Request(0, 0)
33 {
34 msg.checkType(Ipc::mtCacheMgrRequest);
35 msg.getPod(requestorId);
36 msg.getPod(requestId);
37 params = ActionParams(msg);
38
39 conn = new Comm::Connection;
40 conn->fd = msg.getFd();
41 // For now we just have the FD.
42 // Address and connectio details wil be pulled/imported by the component later
43 }
44
45 void
46 Mgr::Request::pack(Ipc::TypedMsgHdr& msg) const
47 {
48 msg.setType(Ipc::mtCacheMgrRequest);
49 msg.putPod(requestorId);
50 msg.putPod(requestId);
51 params.pack(msg);
52
53 msg.putFd(conn->fd);
54 }
55
56 Ipc::Request::Pointer
57 Mgr::Request::clone() const
58 {
59 return new Request(*this);
60 }