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