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