From: Francesco Chemolli Date: Sat, 10 Dec 2011 16:29:31 +0000 (+0100) Subject: Moved statCounter out of globals.h into own object file. X-Git-Tag: BumpSslServerFirst.take05~12^2~120^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4f1fdaea21eb2db3165b6a5a95377add54818e7;p=thirdparty%2Fsquid.git Moved statCounter out of globals.h into own object file. Changed some operator++ from postfix to prefix. --- diff --git a/src/CacheDigest.cc b/src/CacheDigest.cc index ac26bde4f8..efa0d65288 100644 --- a/src/CacheDigest.cc +++ b/src/CacheDigest.cc @@ -34,7 +34,7 @@ */ #include "squid.h" -#include "StatHist.h" +#include "StatCounters.h" #include "Store.h" #if USE_CACHE_DIGESTS diff --git a/src/DiskIO/DiskDaemon/DiskdFile.cc b/src/DiskIO/DiskDaemon/DiskdFile.cc index 10e6c52137..021e10a70c 100644 --- a/src/DiskIO/DiskDaemon/DiskdFile.cc +++ b/src/DiskIO/DiskDaemon/DiskdFile.cc @@ -47,6 +47,7 @@ #include "DiskIO/IORequestor.h" #include "DiskIO/ReadRequest.h" #include "DiskIO/WriteRequest.h" +#include "StatCounters.h" CBDATA_CLASS_INIT(DiskdFile); void * @@ -275,7 +276,7 @@ DiskdFile::completed(diomsg *M) void DiskdFile::openDone(diomsg *M) { - statCounter.syscalls.disk.opens++; + ++statCounter.syscalls.disk.opens; debugs(79, 3, "storeDiskdOpenDone: status " << M->status); if (M->status < 0) { @@ -292,7 +293,7 @@ DiskdFile::openDone(diomsg *M) void DiskdFile::createDone(diomsg *M) { - statCounter.syscalls.disk.opens++; + ++statCounter.syscalls.disk.opens; debugs(79, 3, "storeDiskdCreateDone: status " << M->status); if (M->status < 0) { @@ -355,7 +356,7 @@ DiskdFile::ioCompleted() void DiskdFile::closeDone(diomsg * M) { - statCounter.syscalls.disk.closes++; + ++statCounter.syscalls.disk.closes; debugs(79, 3, "DiskdFile::closeDone: status " << M->status); if (M->status < 0) { @@ -376,7 +377,7 @@ DiskdFile::closeDone(diomsg * M) void DiskdFile::readDone(diomsg * M) { - statCounter.syscalls.disk.reads++; + ++statCounter.syscalls.disk.reads; debugs(79, 3, "DiskdFile::readDone: status " << M->status); assert (M->requestor); ReadRequest::Pointer readRequest = dynamic_cast(M->requestor); @@ -400,7 +401,7 @@ DiskdFile::readDone(diomsg * M) void DiskdFile::writeDone(diomsg *M) { - statCounter.syscalls.disk.writes++; + ++statCounter.syscalls.disk.writes; debugs(79, 3, "storeDiskdWriteDone: status " << M->status); assert (M->requestor); WriteRequest::Pointer writeRequest = dynamic_cast(M->requestor); diff --git a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc index 64c70128c5..2f271b336e 100644 --- a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc +++ b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc @@ -46,6 +46,7 @@ #include "diomsg.h" /* for statfs */ #include "Store.h" +#include "StatCounters.h" #include "SquidTime.h" diskd_stats_t diskd_stats; @@ -293,7 +294,7 @@ void DiskdIOStrategy::unlinkDone(diomsg * M) { debugs(79, 3, "storeDiskdUnlinkDone: file " << shm.buf + M->shm_offset << " status " << M->status); - statCounter.syscalls.disk.unlinks++; + ++statCounter.syscalls.disk.unlinks; if (M->status < 0) diskd_stats.unlink.fail++; diff --git a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc index 0e2f0aed97..4bf6accf33 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc @@ -41,6 +41,7 @@ #include "DiskIO/IORequestor.h" #include "DiskIO/ReadRequest.h" #include "DiskIO/WriteRequest.h" +#include "StatCounters.h" /* === PUBLIC =========================================================== */ @@ -83,7 +84,7 @@ DiskThreadsDiskFile::~DiskThreadsDiskFile() void DiskThreadsDiskFile::open(int flags, mode_t mode, RefCount callback) { - statCounter.syscalls.disk.opens++; + ++statCounter.syscalls.disk.opens; #if !ASYNC_OPEN fd = file_open(path_, flags); @@ -118,7 +119,7 @@ DiskThreadsDiskFile::read(ReadRequest * request) debugs(79, 3, "DiskThreadsDiskFile::read: " << this << ", size " << request->len); assert (fd > -1); assert (ioRequestor.getRaw()); - statCounter.syscalls.disk.reads++; + ++statCounter.syscalls.disk.reads; ++inProgressIOs; #if ASYNC_READ @@ -132,7 +133,7 @@ DiskThreadsDiskFile::read(ReadRequest * request) void DiskThreadsDiskFile::create(int flags, mode_t mode, RefCount callback) { - statCounter.syscalls.disk.opens++; + ++statCounter.syscalls.disk.opens; #if !ASYNC_CREATE int fd = file_open(path_, flags); @@ -203,7 +204,7 @@ DiskThreadsDiskFile::openDone(int unused, const char *unused2, int anFD, int err void DiskThreadsDiskFile::doClose() { if (fd > -1) { - statCounter.syscalls.disk.closes++; + ++statCounter.syscalls.disk.closes; #if ASYNC_CLOSE aioClose(fd); @@ -246,7 +247,7 @@ void DiskThreadsDiskFile::write(WriteRequest * writeRequest) { debugs(79, 3, "DiskThreadsDiskFile::write: FD " << fd); - statCounter.syscalls.disk.writes++; + ++statCounter.syscalls.disk.writes; ++inProgressIOs; #if ASYNC_WRITE diff --git a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc index 1ba1ecf766..c885b29308 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc @@ -40,6 +40,7 @@ #include "DiskThreadsIOStrategy.h" #include "fde.h" #include "mgr/Registration.h" +#include "StatCounters.h" /* for statfs */ #include "Store.h" @@ -263,6 +264,6 @@ DiskThreadsIOStrategy::unlinkdUseful() const void DiskThreadsIOStrategy::unlinkFile(char const *path) { - statCounter.syscalls.disk.unlinks++; + ++statCounter.syscalls.disk.unlinks; aioUnlink(path, NULL, NULL); } diff --git a/src/DiskIO/IpcIo/IpcIoFile.cc b/src/DiskIO/IpcIo/IpcIoFile.cc index 8c0a3ecef4..becbf2e9d3 100644 --- a/src/DiskIO/IpcIo/IpcIoFile.cc +++ b/src/DiskIO/IpcIo/IpcIoFile.cc @@ -17,6 +17,7 @@ #include "ipc/StrandSearch.h" #include "ipc/UdsOp.h" #include "ipc/mem/Pages.h" +#include "StatCounters.h" #include "SquidTime.h" CBDATA_CLASS_INIT(IpcIoFile); @@ -628,7 +629,7 @@ diskerRead(IpcIoMsg &ipcIo) char *const buf = Ipc::Mem::PagePointer(ipcIo.page); const ssize_t read = pread(TheFile, buf, min(ipcIo.len, Ipc::Mem::PageSize()), ipcIo.offset); - statCounter.syscalls.disk.reads++; + ++statCounter.syscalls.disk.reads; fd_bytes(TheFile, read, FD_READ); if (read >= 0) { @@ -650,7 +651,7 @@ diskerWrite(IpcIoMsg &ipcIo) { const char *const buf = Ipc::Mem::PagePointer(ipcIo.page); const ssize_t wrote = pwrite(TheFile, buf, min(ipcIo.len, Ipc::Mem::PageSize()), ipcIo.offset); - statCounter.syscalls.disk.writes++; + ++statCounter.syscalls.disk.writes; fd_bytes(TheFile, wrote, FD_WRITE); if (wrote >= 0) { diff --git a/src/Makefile.am b/src/Makefile.am index a489addf57..0671627f97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -426,6 +426,7 @@ squid_SOURCES = \ SquidNew.cc \ stat.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ String.cc \ @@ -1084,6 +1085,7 @@ tests_testHttpReply_SOURCES=\ tests/stub_debug.cc \ tests/stub_HelperChildConfig.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ tests/stub_StatHist.cc \ tests/stub_store.cc \ @@ -1361,6 +1363,7 @@ tests_testCacheManager_SOURCES = \ SquidMath.cc \ stat.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -1485,6 +1488,7 @@ tests_testDiskIO_SOURCES = \ refresh.cc \ RemovalPolicy.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -1690,6 +1694,7 @@ tests_testEvent_SOURCES = \ SquidMath.h \ stat.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -1881,6 +1886,7 @@ tests_testEventLoop_SOURCES = \ SquidMath.cc \ stat.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -2068,6 +2074,7 @@ tests_test_http_range_SOURCES = \ SquidMath.cc \ stat.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -2294,6 +2301,7 @@ tests_testHttpRequest_SOURCES = \ SquidMath.cc \ stat.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -2410,6 +2418,7 @@ tests_testStore_SOURCES= \ RemovalPolicy.cc \ refresh.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -2643,6 +2652,7 @@ tests_testUfs_SOURCES = \ HttpHdrScTarget.cc \ url.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ HttpHdrRange.cc \ @@ -2737,6 +2747,7 @@ tests_testRock_SOURCES = \ Parsing.cc \ RemovalPolicy.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ @@ -2906,6 +2917,7 @@ tests_testCoss_SOURCES = \ HttpHdrScTarget.cc \ url.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ HttpHdrRange.cc \ @@ -3042,6 +3054,7 @@ tests_testNull_SOURCES = \ HttpHdrScTarget.cc \ url.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ HttpHdrRange.cc \ @@ -3193,6 +3206,7 @@ tests_testURL_SOURCES = \ SquidMath.cc \ stat.cc \ StatCounters.h \ + StatCounters.cc \ StatHist.h \ StatHist.cc \ stmem.cc \ diff --git a/src/PeerDigest.h b/src/PeerDigest.h index 9f805e15a2..789e3a55ba 100644 --- a/src/PeerDigest.h +++ b/src/PeerDigest.h @@ -39,6 +39,7 @@ #if USE_CACHE_DIGESTS #include "cbdata.h" +#include "StatCounters.h" /* for cd_guess_stats */ struct _Version { short int current; /* current version */ diff --git a/src/Server.cc b/src/Server.cc index be3ad71a12..13e1d76adc 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -44,6 +44,7 @@ #include "HttpReply.h" #include "errorpage.h" #include "err_detail_type.h" +#include "StatCounters.h" #include "SquidTime.h" #if USE_ADAPTATION @@ -365,7 +366,7 @@ ServerStateData::sentRequestBody(const CommIoCbParams &io) if (io.size > 0) { fd_bytes(io.fd, io.size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, io.size); + kb_incr(&(statCounter.server.all.kbytes_out), io.size); // kids should increment their counters } diff --git a/src/StatCounters.cc b/src/StatCounters.cc new file mode 100644 index 0000000000..53d62dfa66 --- /dev/null +++ b/src/StatCounters.cc @@ -0,0 +1,36 @@ +/* + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + * AUTHOR: Francesco Chemolli (Harvest-derived) + * + */ + +#include "config.h" +#include "StatCounters.h" + +StatCounters *StatCounters::counters; +StatCounters statCounter; diff --git a/src/StatCounters.h b/src/StatCounters.h index f871338a8b..4e57e70955 100644 --- a/src/StatCounters.h +++ b/src/StatCounters.h @@ -1,10 +1,33 @@ /* - * StatCounters.h + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + * AUTHOR: Francesco Chemolli (Harvest-derived) * - * Created on: Dec 9, 2011 - * Author: kinkie */ - #ifndef STATCOUNTERS_H_ #define STATCOUNTERS_H_ @@ -32,7 +55,6 @@ public: */ class StatCounters { public: - struct { int clients; int requests; @@ -156,7 +178,10 @@ public: int outs; int ins; } swap; + +private: }; +extern StatCounters statCounter; #endif /* STATCOUNTERS_H_ */ diff --git a/src/client_db.cc b/src/client_db.cc index 213ff75579..cbf1387eb7 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -40,6 +40,7 @@ #include "mgr/Registration.h" #include "SquidMath.h" #include "SquidTime.h" +#include "StatCounters.h" #include "Store.h" @@ -92,7 +93,7 @@ clientdbAdd(const Ip::Address &addr) c->prevTime=current_dtime;/* put current time to have something sensible here */ #endif hash_join(client_table, &c->hash); - statCounter.client_http.clients++; + ++statCounter.client_http.clients; if ((statCounter.client_http.clients > max_clients) && !cleanup_running && cleanup_scheduled < 2) { cleanup_scheduled++; @@ -404,7 +405,7 @@ clientdbGC(void *unused) clientdbFreeItem(c); - statCounter.client_http.clients--; + --statCounter.client_http.clients; cleanup_removed++; } diff --git a/src/client_side.cc b/src/client_side.cc index f134d88dee..e31e80c767 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -427,15 +427,15 @@ clientIdentDone(const char *ident, void *data) void clientUpdateStatCounters(log_type logType) { - statCounter.client_http.requests++; + ++statCounter.client_http.requests; if (logTypeIsATcpHit(logType)) - statCounter.client_http.hits++; + ++statCounter.client_http.hits; if (logType == LOG_TCP_HIT) - statCounter.client_http.disk_hits++; + ++statCounter.client_http.disk_hits; else if (logType == LOG_TCP_MEM_HIT) - statCounter.client_http.mem_hits++; + ++statCounter.client_http.mem_hits; } void @@ -2822,7 +2822,7 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) if (io.flag == COMM_OK) { if (io.size > 0) { - kb_incr(&statCounter.client_http.kbytes_in, io.size); + kb_incr(&(statCounter.client_http.kbytes_in), io.size); // may comm_close or setReplyToError if (!handleReadData(io.buf, io.size)) diff --git a/src/comm.cc b/src/comm.cc index 5627d11589..881a3c8a69 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -58,6 +58,7 @@ #include "ip/QosConfig.h" #include "ip/tools.h" #include "ClientInfo.h" +#include "StatCounters.h" #if USE_SSL #include "ssl/support.h" #endif diff --git a/src/comm/ModPoll.cc b/src/comm/ModPoll.cc index b190500dff..e57a34c6b9 100644 --- a/src/comm/ModPoll.cc +++ b/src/comm/ModPoll.cc @@ -41,7 +41,7 @@ #include "ICP.h" #include "mgr/Registration.h" #include "SquidTime.h" -#include "StatHist.h" +#include "StatCounters.h" #include "Store.h" #if HAVE_POLL_H @@ -642,7 +642,7 @@ Comm::SelectLoopInit(void) static void commIncomingStats(StoreEntry * sentry) { - StatCounters *f = &statCounter; + StatCounters *f = StatCounters::GetCounters(); storeAppendPrintf(sentry, "Current incoming_icp_interval: %d\n", incoming_icp_interval >> INCOMING_FACTOR); storeAppendPrintf(sentry, "Current incoming_dns_interval: %d\n", diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index 221394bf20..f3feb7b170 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -44,6 +44,7 @@ #include "ip/Intercept.h" #include "protos.h" #include "SquidTime.h" +#include "StatCounters.h" namespace Comm { @@ -296,7 +297,7 @@ comm_err_t Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) { PROF_start(comm_accept); - statCounter.syscalls.sock.accepts++; + ++statCounter.syscalls.sock.accepts; int sock; struct addrinfo *gai = NULL; details->local.InitAddrInfo(gai); diff --git a/src/comm/Write.cc b/src/comm/Write.cc index 4d5cf46a69..88783d75a2 100644 --- a/src/comm/Write.cc +++ b/src/comm/Write.cc @@ -6,6 +6,7 @@ #include "comm/IoCallback.h" #include "comm/Write.h" #include "fde.h" +#include "StatCounters.h" #include "SquidTime.h" #include "MemBuf.h" @@ -108,7 +109,7 @@ Comm::HandleWrite(int fd, void *data) #endif /* USE_DELAY_POOLS */ fd_bytes(fd, len, FD_WRITE); - statCounter.syscalls.sock.writes++; + ++statCounter.syscalls.sock.writes; // After each successful partial write, // reset fde::writeStart to the current time. fd_table[fd].writeStart = squid_curtime; diff --git a/src/disk.cc b/src/disk.cc index c5d0c51a98..04e1a53951 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -36,6 +36,7 @@ #include "comm/Loops.h" #include "fde.h" #include "MemBuf.h" +#include "StatCounters.h" static PF diskHandleRead; static PF diskHandleWrite; @@ -442,7 +443,7 @@ diskHandleRead(int fd, void *data) #endif debugs(6, 3, "diskHandleRead: FD " << fd << " seeking to offset " << ctrl_dat->offset); lseek(fd, ctrl_dat->offset, SEEK_SET); /* XXX ignore return? */ - statCounter.syscalls.disk.seeks++; + ++statCounter.syscalls.disk.seeks; F->disk.offset = ctrl_dat->offset; } diff --git a/src/fqdncache.cc b/src/fqdncache.cc index b01d2434e4..08b71d98ac 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -38,7 +38,7 @@ #include "event.h" #include "mgr/Registration.h" #include "SquidTime.h" -#include "StatHist.h" +#include "StatCounters.h" #include "Store.h" #include "wordlist.h" diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 609c32842c..8b856d2806 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -44,6 +44,7 @@ #include "Parsing.h" #include "SquidMath.h" #include "SquidTime.h" +#include "StatCounters.h" #include "SwapDir.h" #include "swap_log_op.h" @@ -1144,7 +1145,7 @@ UFSSwapDir::DirClean(int swap_index) debugs(36, 3, "storeDirClean: Cleaning file "<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << files[n]); snprintf(p2, MAXPATHLEN + 1, "%s/%08X", p1, files[n]); safeunlink(p2, 0); - statCounter.swap.files_cleaned++; + ++statCounter.swap.files_cleaned; } debugs(36, 3, "Cleaned " << k << " unused files from " << p1); diff --git a/src/ftp.cc b/src/ftp.cc index ae73d6eb9a..7b7e6edd80 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -54,6 +54,7 @@ #include "Server.h" #include "SquidString.h" #include "SquidTime.h" +#include "StatCounters.h" #include "Store.h" #include "URLScheme.h" #include "wordlist.h" @@ -1257,8 +1258,8 @@ FtpStateData::dataRead(const CommIoCbParams &io) debugs(9, 3, HERE << "ftpDataRead: FD " << io.fd << " Read " << io.size << " bytes"); if (io.size > 0) { - kb_incr(&statCounter.server.all.kbytes_in, io.size); - kb_incr(&statCounter.server.ftp.kbytes_in, io.size); + kb_incr(&(statCounter.server.all.kbytes_in), io.size); + kb_incr(&(statCounter.server.ftp.kbytes_in), io.size); } if (io.flag == COMM_ERR_CLOSING) @@ -1613,8 +1614,8 @@ FtpStateData::ftpWriteCommandCallback(const CommIoCbParams &io) if (io.size > 0) { fd_bytes(io.fd, io.size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, io.size); - kb_incr(&statCounter.server.ftp.kbytes_out, io.size); + kb_incr(&(statCounter.server.all.kbytes_out), io.size); + kb_incr(&(statCounter.server.ftp.kbytes_out), io.size); } if (io.flag == COMM_ERR_CLOSING) @@ -1754,8 +1755,8 @@ void FtpStateData::ftpReadControlReply(const CommIoCbParams &io) debugs(9, 3, "ftpReadControlReply: FD " << io.fd << ", Read " << io.size << " bytes"); if (io.size > 0) { - kb_incr(&statCounter.server.all.kbytes_in, io.size); - kb_incr(&statCounter.server.ftp.kbytes_in, io.size); + kb_incr(&(statCounter.server.all.kbytes_in), io.size); + kb_incr(&(statCounter.server.ftp.kbytes_in), io.size); } if (io.flag == COMM_ERR_CLOSING) @@ -3317,7 +3318,7 @@ void FtpStateData::sentRequestBody(const CommIoCbParams &io) { if (io.size > 0) - kb_incr(&statCounter.server.ftp.kbytes_out, io.size); + kb_incr(&(statCounter.server.ftp.kbytes_out), io.size); ServerStateData::sentRequestBody(io); } diff --git a/src/globals.h b/src/globals.h index 104b3ecc02..4165e0090c 100644 --- a/src/globals.h +++ b/src/globals.h @@ -41,7 +41,6 @@ /* for ERROR_BUF_SZ, BUFSIZ, MAXHTTPPORTS */ #include "defines.h" -#include "StatCounters.h" /* for iostats */ #include "structs.h" @@ -110,7 +109,6 @@ extern "C" { extern int shutting_down; /* 0 */ extern int reconfiguring; /* 0 */ extern time_t hit_only_mode_until; /* 0 */ - extern StatCounters statCounter; extern double request_failure_ratio; /* 0.0 */ extern int store_hash_buckets; /* 0 */ extern hash_table *store_table; /* NULL */ diff --git a/src/gopher.cc b/src/gopher.cc index 5a527b0853..894d72f0af 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -48,6 +48,7 @@ #include "MemBuf.h" #include "forward.h" #include "rfc1738.h" +#include "StatCounters.h" #include "SquidTime.h" /** @@ -769,8 +770,8 @@ gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm delayId.bytesIn(len); #endif - kb_incr(&statCounter.server.all.kbytes_in, len); - kb_incr(&statCounter.server.other.kbytes_in, len); + kb_incr(&(statCounter.server.all.kbytes_in), len); + kb_incr(&(statCounter.server.other.kbytes_in), len); } debugs(10, 5, HERE << conn << " read len=" << len); @@ -844,8 +845,8 @@ gopherSendComplete(const Comm::ConnectionPointer &conn, char *buf, size_t size, if (size > 0) { fd_bytes(conn->fd, size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, size); - kb_incr(&statCounter.server.other.kbytes_out, size); + kb_incr(&(statCounter.server.all.kbytes_out), size); + kb_incr(&(statCounter.server.other.kbytes_out), size); } if (errflag) { diff --git a/src/htcp.cc b/src/htcp.cc index 20101df6b5..1b8272b353 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -47,6 +47,7 @@ #include "ip/tools.h" #include "MemBuf.h" #include "SquidTime.h" +#include "StatCounters.h" #include "Store.h" #include "StoreClient.h" #include "compat/xalloc.h" diff --git a/src/http.cc b/src/http.cc index 232b125cc3..60d0738ce2 100644 --- a/src/http.cc +++ b/src/http.cc @@ -68,6 +68,7 @@ #include "protos.h" #include "rfc1738.h" #include "SquidTime.h" +#include "StatCounters.h" #include "Store.h" @@ -1095,8 +1096,8 @@ HttpStateData::readReply(const CommIoCbParams &io) delayId.bytesIn(len); #endif - kb_incr(&statCounter.server.all.kbytes_in, len); - kb_incr(&statCounter.server.http.kbytes_in, len); + kb_incr(&(statCounter.server.all.kbytes_in), len); + kb_incr(&(statCounter.server.http.kbytes_in), len); IOStats.Http.reads++; for (clen = len - 1, bin = 0; clen; bin++) @@ -1465,8 +1466,8 @@ HttpStateData::wroteLast(const CommIoCbParams &io) if (io.size > 0) { fd_bytes(io.fd, io.size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, io.size); - kb_incr(&statCounter.server.http.kbytes_out, io.size); + kb_incr(&(statCounter.server.all.kbytes_out), io.size); + kb_incr(&(statCounter.server.http.kbytes_out), io.size); } if (io.flag == COMM_ERR_CLOSING) diff --git a/src/icp_v2.cc b/src/icp_v2.cc index b0835343c0..9f3d057f34 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -46,7 +46,7 @@ #include "acl/Acl.h" #include "AccessLogEntry.h" #include "wordlist.h" -#include "StatHist.h" +#include "StatCounters.h" #include "SquidTime.h" #include "SwapDir.h" #include "icmp/net_db.h" diff --git a/src/ipcache.cc b/src/ipcache.cc index 570d83f8ad..8eb69b2925 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -40,7 +40,7 @@ #include "ipcache.h" #include "mgr/Registration.h" #include "SquidTime.h" -#include "StatHist.h" +#include "StatCounters.h" #include "Store.h" #include "wordlist.h" diff --git a/src/main.cc b/src/main.cc index 5fdc1c9b89..2a94775a57 100644 --- a/src/main.cc +++ b/src/main.cc @@ -82,6 +82,7 @@ #include "ipc/Strand.h" #include "ip/tools.h" #include "SquidTime.h" +#include "StatCounters.h" #include "SwapDir.h" #include "forward.h" #include "MemPool.h" diff --git a/src/stat.cc b/src/stat.cc index 033782e017..0f0b4d7463 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -54,7 +54,7 @@ #include "MemBuf.h" #include "SquidMath.h" #include "SquidTime.h" -#include "StatHist.h" +#include "StatCounters.h" #include "mgr/CountersAction.h" #include "mgr/FunAction.h" #include "mgr/InfoAction.h" diff --git a/src/store.cc b/src/store.cc index f017ff874b..9e9cb3b3bb 100644 --- a/src/store.cc +++ b/src/store.cc @@ -47,6 +47,7 @@ #include "HttpRequest.h" #include "MemObject.h" #include "mem_node.h" +#include "StatCounters.h" #include "StoreMeta.h" #include "SwapDir.h" #include "StoreIOState.h" diff --git a/src/store_client.cc b/src/store_client.cc index 55ed6a2dfe..f8bd81bfdf 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -40,6 +40,7 @@ #include "Store.h" #include "HttpReply.h" #include "MemObject.h" +#include "StatCounters.h" #include "StoreMeta.h" #include "StoreMetaUnpacker.h" #if USE_DELAY_POOLS diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 9962646f51..fe88871132 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -35,6 +35,7 @@ #include "squid.h" #include "event.h" +#include "StatCounters.h" #include "Store.h" #include "SwapDir.h" #include "StoreSearch.h" diff --git a/src/store_swapin.cc b/src/store_swapin.cc index d993b62d06..6d9d105a1e 100644 --- a/src/store_swapin.cc +++ b/src/store_swapin.cc @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "StatCounters.h" #include "StoreClient.h" #include "Store.h" @@ -84,7 +85,7 @@ storeSwapInFileClosed(void *data, int errflag, StoreIOState::Pointer self) sc->callback(0, errflag ? true : false); } - statCounter.swap.ins++; + ++statCounter.swap.ins; } static void diff --git a/src/store_swapout.cc b/src/store_swapout.cc index aa4eefdb79..a11638bd6f 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -41,6 +41,7 @@ #include "mem_node.h" #include "MemObject.h" #include "SwapDir.h" +#include "StatCounters.h" #include "swap_log_op.h" static void storeSwapOutStart(StoreEntry * e); @@ -365,7 +366,7 @@ storeSwapOutFileClosed(void *data, int errflag, StoreIOState::Pointer self) storeDirSwapLog(e, SWAP_LOG_ADD); } - statCounter.swap.outs++; + ++statCounter.swap.outs; } debugs(20, 3, "storeSwapOutFileClosed: " << __FILE__ << ":" << __LINE__); diff --git a/src/tunnel.cc b/src/tunnel.cc index 67c0b5e0e4..dbad0d7f09 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -51,6 +51,7 @@ #include "MemBuf.h" #include "http.h" #include "PeerSelectState.h" +#include "StatCounters.h" class TunnelStateData { @@ -249,8 +250,8 @@ TunnelStateData::readServer(char *buf, size_t len, comm_err_t errcode, int xerrn if (len > 0) { server.bytesIn(len); - kb_incr(&statCounter.server.all.kbytes_in, len); - kb_incr(&statCounter.server.other.kbytes_in, len); + kb_incr(&(statCounter.server.all.kbytes_in), len); + kb_incr(&(statCounter.server.other.kbytes_in), len); } copy (len, errcode, xerrno, server, client, WriteClientDone); @@ -293,7 +294,7 @@ TunnelStateData::readClient(char *buf, size_t len, comm_err_t errcode, int xerrn if (len > 0) { client.bytesIn(len); - kb_incr(&statCounter.client_http.kbytes_in, len); + kb_incr(&(statCounter.client_http.kbytes_in), len); } copy (len, errcode, xerrno, client, server, WriteServerDone); @@ -369,8 +370,8 @@ TunnelStateData::writeServerDone(char *buf, size_t len, comm_err_t flag, int xer } /* Valid data */ - kb_incr(&statCounter.server.all.kbytes_out, len); - kb_incr(&statCounter.server.other.kbytes_out, len); + kb_incr(&(statCounter.server.all.kbytes_out), len); + kb_incr(&(statCounter.server.other.kbytes_out), len); client.dataSent(len); /* If the other end has closed, so should we */ @@ -432,7 +433,7 @@ TunnelStateData::writeClientDone(char *buf, size_t len, comm_err_t flag, int xer } /* Valid data */ - kb_incr(&statCounter.client_http.kbytes_out, len); + kb_incr(&(statCounter.client_http.kbytes_out), len); server.dataSent(len); /* If the other end has closed, so should we */ diff --git a/src/unlinkd.cc b/src/unlinkd.cc index 96dbf9d12c..f79d9634b8 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -35,6 +35,7 @@ #include "squid.h" #include "SquidTime.h" +#include "StatCounters.h" #include "SwapDir.h" #include "fde.h" #include "xusleep.h" @@ -131,13 +132,13 @@ unlinkdUnlink(const char *path) return; } - statCounter.unlink.requests++; + ++statCounter.unlink.requests; /* * Increment this syscalls counter here, even though the syscall * is executed by the helper process. We try to be consistent * in counting unlink operations. */ - statCounter.syscalls.disk.unlinks++; + ++statCounter.syscalls.disk.unlinks; queuelen++; } diff --git a/src/whois.cc b/src/whois.cc index 27217e9fc1..9573c72ea4 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -42,6 +42,7 @@ #include "comm.h" #include "HttpRequest.h" #include "forward.h" +#include "StatCounters.h" #define WHOIS_PORT 43 @@ -169,8 +170,8 @@ WhoisState::readReply(const Comm::ConnectionPointer &conn, char *aBuffer, size_t if (!dataWritten) setReplyToOK(entry); - kb_incr(&statCounter.server.all.kbytes_in, aBufferLength); - kb_incr(&statCounter.server.http.kbytes_in, aBufferLength); + kb_incr(&(statCounter.server.all.kbytes_in), aBufferLength); + kb_incr(&(statCounter.server.http.kbytes_in), aBufferLength); /* No range support, we always grab it all */ dataWritten = true;