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