]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/mgr/InfoAction.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / InfoAction.cc
index eb5760ba0b86236bc867a0d2a74444a2e15c35ac..19d04095f626e88f0ec499d42c9e3de104613370 100644 (file)
@@ -1,31 +1,36 @@
 /*
- * $Id$
- *
- * DEBUG: section 16    Cache Manager API
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
  *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-#include "config.h"
+/* DEBUG: section 16    Cache Manager API */
+
+#include "squid.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
+#include "globals.h"
 #include "HttpReply.h"
 #include "ipc/Messages.h"
-#include "ipc/UdsOp.h"
 #include "ipc/TypedMsgHdr.h"
+#include "ipc/UdsOp.h"
 #include "mgr/Filler.h"
 #include "mgr/InfoAction.h"
 #include "mgr/Request.h"
 #include "mgr/Response.h"
 #include "SquidTime.h"
 #include "Store.h"
+#include "tools.h"
 
-
-extern void GetInfo(Mgr::InfoActionData& stats);
-extern void DumpInfo(Mgr::InfoActionData& stats, StoreEntry* sentry);
-extern void DumpMallocStatistics(StoreEntry* sentry);
+void GetInfo(Mgr::InfoActionData& stats);
+void DumpInfo(Mgr::InfoActionData& stats, StoreEntry* sentry);
+void DumpMallocStatistics(StoreEntry* sentry);
 
 Mgr::InfoActionData::InfoActionData()
 {
-    xmemset(this, 0, sizeof(*this));
+    memset(this, 0, sizeof(*this));
 }
 
 Mgr::InfoActionData&
@@ -57,12 +62,9 @@ Mgr::InfoActionData::operator += (const InfoActionData& stats)
     request_hit_mem_ratio60 += stats.request_hit_mem_ratio60;
     request_hit_disk_ratio5 += stats.request_hit_disk_ratio5;
     request_hit_disk_ratio60 += stats.request_hit_disk_ratio60;
-    store_swap_size += stats.store_swap_size;
-    store_swap_max_size += stats.store_swap_max_size;
-    store_mem_size += stats.store_mem_size;
-    store_pages_max += stats.store_pages_max;
-    store_mem_used += stats.store_mem_used;
-    objects_size += stats.objects_size;
+
+    store += stats.store;
+
     unlink_requests += stats.unlink_requests;
     http_requests5 += stats.http_requests5;
     http_requests60 += stats.http_requests60;
@@ -84,50 +86,21 @@ Mgr::InfoActionData::operator += (const InfoActionData& stats)
     cpu_usage += stats.cpu_usage;
     cpu_usage5 += stats.cpu_usage5;
     cpu_usage60 += stats.cpu_usage60;
-#if HAVE_SBRK
-    proc_data_seg += stats.proc_data_seg;
-#endif
     maxrss += stats.maxrss;
     page_faults += stats.page_faults;
 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
     ms_bytes_total += stats.ms_bytes_total;
     ms_bytes_free += stats.ms_bytes_free;
-#elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-    mp_arena += stats.mp_arena;
-    mp_uordblks += stats.mp_uordblks;
-    mp_ordblks += stats.mp_ordblks;
-    mp_usmblks += stats.mp_usmblks;
-    mp_smblks += stats.mp_smblks;
-    mp_hblkhd += stats.mp_hblkhd;
-    mp_hblks += stats.mp_hblks;
-    mp_fsmblks += stats.mp_fsmblks;
-    mp_fordblks += stats.mp_fordblks;
-#if HAVE_STRUCT_MALLINFO_MXFAST
-    mp_mxfast += stats.mp_mxfast;
-    mp_nlblks += stats.mp_nlblks;
-    mp_grain += stats.mp_grain;
-    mp_uordbytes += stats.mp_uordbytes;
-    mp_allocated += stats.mp_allocated;
-    mp_treeoverhead += stats.mp_treeoverhead;
-#endif
 #endif
     total_accounted += stats.total_accounted;
-#if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-    mem_pool_allocated += stats.mem_pool_allocated;
-#endif
     gb_saved_count += stats.gb_saved_count;
     gb_freed_count += stats.gb_freed_count;
     max_fd += stats.max_fd;
-    biggest_fd += stats.biggest_fd;
+    biggest_fd = max(biggest_fd, stats.biggest_fd);
     number_fd += stats.number_fd;
     opening_fd += stats.opening_fd;
     num_fd_free += stats.num_fd_free;
     reserved_fd += stats.reserved_fd;
-    store_open_disk_fd += stats.store_open_disk_fd;
-    store_entries += stats.store_entries;
-    store_mem_entries += stats.store_mem_entries;
-    hot_obj_count += stats.hot_obj_count;
-    n_disk_objects += stats.n_disk_objects;
     ++count;
 
     return *this;
@@ -139,8 +112,8 @@ Mgr::InfoAction::Create(const CommandPointer &cmd)
     return new InfoAction(cmd);
 }
 
-Mgr::InfoAction::InfoAction(const CommandPointer &cmd):
-        Action(cmd), data()
+Mgr::InfoAction::InfoAction(const CommandPointer &aCmd):
+    Action(aCmd), data()
 {
     debugs(16, 5, HERE);
 }
@@ -156,10 +129,10 @@ void
 Mgr::InfoAction::respond(const Request& request)
 {
     debugs(16, 5, HERE);
-    int fd = Ipc::ImportFdIntoComm(request.fd, SOCK_STREAM, IPPROTO_TCP, Ipc::fdnHttpSocket);
-    Must(fd >= 0);
+    Ipc::ImportFdIntoComm(request.conn, SOCK_STREAM, IPPROTO_TCP, Ipc::fdnHttpSocket);
+    Must(Comm::IsConnOpen(request.conn));
     Must(request.requestId != 0);
-    AsyncJob::Start(new Mgr::Filler(this, fd, request.requestId));
+    AsyncJob::Start(new Mgr::Filler(this, request.conn, request.requestId));
 }
 
 void
@@ -175,10 +148,10 @@ Mgr::InfoAction::dump(StoreEntry* entry)
     Must(entry != NULL);
 
 #if XMALLOC_STATISTICS
-    if (UsingSmp() && IamWorkerProcess())
+    if (UsingSmp())
         storeAppendPrintf(entry, "by kid%d {\n", KidIdentifier);
     DumpMallocStatistics(entry);
-    if (UsingSmp() && IamWorkerProcess())
+    if (UsingSmp())
         storeAppendPrintf(entry, "} by kid%d\n\n", KidIdentifier);
 #endif
     if (IamPrimaryProcess())
@@ -198,3 +171,4 @@ Mgr::InfoAction::unpack(const Ipc::TypedMsgHdr& msg)
     msg.checkType(Ipc::mtCacheMgrResponse);
     msg.getPod(data);
 }
+