]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/IoAction.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / IoAction.cc
CommitLineData
8822ebee 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
8822ebee 3 *
bbc27441
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
8822ebee
AR
7 */
8
bbc27441
AJ
9/* DEBUG: section 16 Cache Manager API */
10
f7f3304a 11#include "squid.h"
8822ebee 12#include "base/TextException.h"
9ce629cf 13#include "IoStats.h"
8822ebee
AR
14#include "ipc/Messages.h"
15#include "ipc/TypedMsgHdr.h"
16#include "mgr/IoAction.h"
17#include "SquidMath.h"
18#include "Store.h"
5bed43d6 19#include "tools.h"
8822ebee 20
82afb125
FC
21void GetIoStats(Mgr::IoActionData& stats);
22void DumpIoStats(Mgr::IoActionData& stats, StoreEntry* sentry);
8822ebee
AR
23
24Mgr::IoActionData::IoActionData()
25{
e297be13 26 memset(this, 0, sizeof(*this));
8822ebee
AR
27}
28
29Mgr::IoActionData&
30Mgr::IoActionData::operator += (const IoActionData& stats)
31{
32 http_reads += stats.http_reads;
9ce629cf 33 for (int i = 0; i < IoStats::histSize; ++i)
8822ebee
AR
34 http_read_hist[i] += stats.http_read_hist[i];
35 ftp_reads += stats.ftp_reads;
9ce629cf 36 for (int i = 0; i < IoStats::histSize; ++i)
8822ebee
AR
37 ftp_read_hist[i] += stats.ftp_read_hist[i];
38 gopher_reads += stats.gopher_reads;
9ce629cf 39 for (int i = 0; i < IoStats::histSize; ++i)
8822ebee
AR
40 gopher_read_hist[i] += stats.gopher_read_hist[i];
41
42 return *this;
43}
44
45Mgr::IoAction::Pointer
46Mgr::IoAction::Create(const CommandPointer &cmd)
47{
48 return new IoAction(cmd);
49}
50
9dca980d 51Mgr::IoAction::IoAction(const CommandPointer &aCmd):
f53969cc 52 Action(aCmd), data()
8822ebee
AR
53{
54 debugs(16, 5, HERE);
55}
56
57void
58Mgr::IoAction::add(const Action& action)
59{
60 debugs(16, 5, HERE);
61 data += dynamic_cast<const IoAction&>(action).data;
62}
63
64void
65Mgr::IoAction::collect()
66{
67 GetIoStats(data);
68}
69
70void
71Mgr::IoAction::dump(StoreEntry* entry)
72{
73 debugs(16, 5, HERE);
74 Must(entry != NULL);
75 DumpIoStats(data, entry);
76}
77
78void
79Mgr::IoAction::pack(Ipc::TypedMsgHdr& msg) const
80{
81 msg.setType(Ipc::mtCacheMgrResponse);
82 msg.putPod(data);
83}
84
85void
86Mgr::IoAction::unpack(const Ipc::TypedMsgHdr& msg)
87{
88 msg.checkType(Ipc::mtCacheMgrResponse);
89 msg.getPod(data);
90}
f53969cc 91