]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/IoAction.cc
merge from parent SslServerCertValidator r12337
[thirdparty/squid.git] / src / mgr / IoAction.cc
1 /*
2 * DEBUG: section 16 Cache Manager API
3 *
4 */
5
6 #include "squid.h"
7 #include "base/TextException.h"
8 #include "IoStats.h"
9 #include "ipc/Messages.h"
10 #include "ipc/TypedMsgHdr.h"
11 #include "mgr/IoAction.h"
12 #include "SquidMath.h"
13 #include "Store.h"
14 #include "tools.h"
15
16 void GetIoStats(Mgr::IoActionData& stats);
17 void DumpIoStats(Mgr::IoActionData& stats, StoreEntry* sentry);
18
19 Mgr::IoActionData::IoActionData()
20 {
21 memset(this, 0, sizeof(*this));
22 }
23
24 Mgr::IoActionData&
25 Mgr::IoActionData::operator += (const IoActionData& stats)
26 {
27 http_reads += stats.http_reads;
28 for (int i = 0; i < IoStats::histSize; ++i)
29 http_read_hist[i] += stats.http_read_hist[i];
30 ftp_reads += stats.ftp_reads;
31 for (int i = 0; i < IoStats::histSize; ++i)
32 ftp_read_hist[i] += stats.ftp_read_hist[i];
33 gopher_reads += stats.gopher_reads;
34 for (int i = 0; i < IoStats::histSize; ++i)
35 gopher_read_hist[i] += stats.gopher_read_hist[i];
36
37 return *this;
38 }
39
40 Mgr::IoAction::Pointer
41 Mgr::IoAction::Create(const CommandPointer &cmd)
42 {
43 return new IoAction(cmd);
44 }
45
46 Mgr::IoAction::IoAction(const CommandPointer &cmd):
47 Action(cmd), data()
48 {
49 debugs(16, 5, HERE);
50 }
51
52 void
53 Mgr::IoAction::add(const Action& action)
54 {
55 debugs(16, 5, HERE);
56 data += dynamic_cast<const IoAction&>(action).data;
57 }
58
59 void
60 Mgr::IoAction::collect()
61 {
62 GetIoStats(data);
63 }
64
65 void
66 Mgr::IoAction::dump(StoreEntry* entry)
67 {
68 debugs(16, 5, HERE);
69 Must(entry != NULL);
70 DumpIoStats(data, entry);
71 }
72
73 void
74 Mgr::IoAction::pack(Ipc::TypedMsgHdr& msg) const
75 {
76 msg.setType(Ipc::mtCacheMgrResponse);
77 msg.putPod(data);
78 }
79
80 void
81 Mgr::IoAction::unpack(const Ipc::TypedMsgHdr& msg)
82 {
83 msg.checkType(Ipc::mtCacheMgrResponse);
84 msg.getPod(data);
85 }