From ab0b336a656d168d132f685ead24c0c18df4a612 Mon Sep 17 00:00:00 2001 From: Ben Summers Date: Mon, 13 Feb 2006 13:35:51 +0000 Subject: Bandwidth usage logging patch from Pascal Lalonde , with minor change to exception handling --- bin/bbstored/BackupStoreDaemon.cpp | 20 +++++++++++++++++++- bin/bbstored/BackupStoreDaemon.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp index 0afdaa5d..2752893a 100644 --- a/bin/bbstored/BackupStoreDaemon.cpp +++ b/bin/bbstored/BackupStoreDaemon.cpp @@ -278,7 +278,25 @@ void BackupStoreDaemon::Connection(SocketStreamTLS &rStream) BackupProtocolServer server(rStream); server.SetLogToSysLog(mExtendedLogging); server.SetTimeout(BACKUP_STORE_TIMEOUT); - server.DoServer(context); + try + { + server.DoServer(context); + } + catch(...) + { + LogConnectionStats(clientCommonName.c_str(), rStream); + throw; + } + LogConnectionStats(clientCommonName.c_str(), rStream); context.CleanUp(); } +void BackupStoreDaemon::LogConnectionStats(const char *commonName, + const SocketStreamTLS &s) +{ + // Log the amount of data transferred + ::syslog(LOG_INFO, "Connection statistics for %s: " + "IN=%lld OUT=%lld TOTAL=%lld\n", commonName, + s.GetBytesRead(), s.GetBytesWritten(), + s.GetBytesRead() + s.GetBytesWritten()); +} diff --git a/bin/bbstored/BackupStoreDaemon.h b/bin/bbstored/BackupStoreDaemon.h index 6c4a45bc..2fbe486d 100644 --- a/bin/bbstored/BackupStoreDaemon.h +++ b/bin/bbstored/BackupStoreDaemon.h @@ -61,6 +61,8 @@ protected: void HousekeepingProcess(); bool CheckForInterProcessMsg(int AccountNum = 0, int MaximumWaitTime = 0); + void LogConnectionStats(const char *commonName, const SocketStreamTLS &s); + private: BackupStoreAccountDatabase *mpAccountDatabase; BackupStoreAccounts *mpAccounts; -- cgit v1.2.3