summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-10 20:11:46 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-10 20:11:46 +0000
commitc72a710f77fedd56d18fad77bec198219e394843 (patch)
tree90ad84df7938184ca382e4fbf716ef37facb246c
parent20d467e5a5473577c0e04b63edecdbbbef7ec9c2 (diff)
Record compression ratio stats for a /stats char (this isnt finished yet)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5921 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/extra/m_ziplink.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp
index 5f3a1cfa4..3c1716c92 100644
--- a/src/modules/extra/m_ziplink.cpp
+++ b/src/modules/extra/m_ziplink.cpp
@@ -61,6 +61,10 @@ class izip_session : public classbase
class ModuleZLib : public Module
{
izip_session sessions[MAX_DESCRIPTORS];
+ float total_out_compressed;
+ float total_in_compressed;
+ float total_out_uncompressed;
+ float total_in_uncompressed;
public:
@@ -68,8 +72,11 @@ class ModuleZLib : public Module
: Module::Module(Me)
{
ServerInstance->PublishInterface("InspSocketHook", this);
+
+ total_out_compressed = total_in_compressed = 0;
+ total_out_uncompressed = total_out_uncompressed = 0;
}
-
+
virtual ~ModuleZLib()
{
}
@@ -198,7 +205,9 @@ class ModuleZLib : public Module
inflateEnd(&session->d_stream);
+ total_in_compressed += readresult;
readresult = session->d_stream.total_out;
+ total_in_uncompressed += session->d_stream.total_out;
buffer[readresult] = 0;
session->need_bytes = 0;
@@ -270,6 +279,11 @@ class ModuleZLib : public Module
break;
}
+ deflateEnd(&session->c_stream);
+
+ total_out_uncompressed += ocount;
+ total_out_compressed += session->c_stream.total_out;
+
int x = htonl(session->c_stream.total_out);
/** XXX: We memcpy it onto the start of the buffer like this to save ourselves a write().
* A memcpy of 4 or so bytes is less expensive and gives the tcp stack more chance of
@@ -278,8 +292,6 @@ class ModuleZLib : public Module
memcpy(compr, &x, sizeof(x));
write(fd, compr, session->c_stream.total_out+4);
- deflateEnd(&session->c_stream);
-
return ocount;
}