]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/icap/History.cc
1 #include "adaptation/icap/History.h"
6 Adaptation::Icap::History::History(): mergeOfIcapHeaders(hoRequest
),
7 lastIcapHeader(hoRequest
), logType(LOG_TAG_NONE
), req_sz(0),
8 pastTime(0), concurrencyLevel(0)
12 Adaptation::Icap::History::History(const Adaptation::Icap::History
& ih
)
17 Adaptation::Icap::History::~History()
19 mergeOfIcapHeaders
.clean();
20 lastIcapHeader
.clean();
28 void Adaptation::Icap::History::assign(const Adaptation::Icap::History
& ih
)
30 mergeOfIcapHeaders
.clean();
31 mergeOfIcapHeaders
.update(&ih
.mergeOfIcapHeaders
, NULL
);
32 lastIcapHeader
.clean();
33 lastIcapHeader
.update(&ih
.lastIcapHeader
, NULL
);
43 pastTime
= ih
.pastTime
;
44 currentStart
= ih
.currentStart
;
45 concurrencyLevel
= ih
.concurrencyLevel
;
46 debugs(93,7, HERE
<< this << " = " << &ih
);
49 Adaptation::Icap::History
& Adaptation::Icap::History::operator=(const History
& ih
)
56 void Adaptation::Icap::History::setIcapLastHeader(const HttpHeader
* lih
)
58 lastIcapHeader
.clean();
59 lastIcapHeader
.update(lih
, NULL
);
62 void Adaptation::Icap::History::mergeIcapHeaders(const HttpHeader
* lih
)
64 mergeOfIcapHeaders
.update(lih
, NULL
);
65 mergeOfIcapHeaders
.compact();
68 void Adaptation::Icap::History::start(const char *context
)
70 if (!concurrencyLevel
++)
71 currentStart
= current_time
;
73 debugs(93,4, HERE
<< "start " << context
<< " level=" << concurrencyLevel
74 << " time=" << pastTime
<< ' ' << this);
77 void Adaptation::Icap::History::stop(const char *context
)
79 if (!concurrencyLevel
) {
80 debugs(93,1, HERE
<< "Internal error: poor history accounting " << this);
84 const int current
= currentTime();
85 debugs(93,4, HERE
<< "stop " << context
<< " level=" << concurrencyLevel
<<
86 " time=" << pastTime
<< '+' << current
<< ' ' << this);
88 if (!--concurrencyLevel
)
92 int Adaptation::Icap::History::processingTime() const
94 const int total
= pastTime
+ currentTime();
95 debugs(93,7, HERE
<< " current total: " << total
<< ' ' << this);
99 int Adaptation::Icap::History::currentTime() const
101 return concurrencyLevel
> 0 ?
102 max(0, tvSubMsec(currentStart
, current_time
)) : 0;