diff options
author | Chris Wilson <chris+github@qwirx.com> | 2006-11-26 19:47:49 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2006-11-26 19:47:49 +0000 |
commit | c05cc844114f1f2289432a9ec220e6c527adbf66 (patch) | |
tree | 8eb251aa52cc3316a2599839e966e18879966a21 /bin/bbstored | |
parent | 042f6b6802eca9249670ae30919d5a398a1cc97d (diff) |
Catch any exceptions while handling a connection and report to user
rather than terminating. Useful for non-forking servers like bbstored on
Windows. (refs #3)
Diffstat (limited to 'bin/bbstored')
-rw-r--r-- | bin/bbstored/BackupStoreDaemon.cpp | 36 | ||||
-rw-r--r-- | bin/bbstored/BackupStoreDaemon.h | 3 |
2 files changed, 36 insertions, 3 deletions
diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp index 74885c57..06d529c3 100644 --- a/bin/bbstored/BackupStoreDaemon.cpp +++ b/bin/bbstored/BackupStoreDaemon.cpp @@ -247,17 +247,49 @@ void BackupStoreDaemon::Run() } } - // -------------------------------------------------------------------------- // // Function // Name: BackupStoreDaemon::Connection(SocketStreamTLS &) -// Purpose: Handles a connection +// Purpose: Handles a connection, by catching exceptions and +// delegating to Connection2 // Created: 2003/08/20 // // -------------------------------------------------------------------------- void BackupStoreDaemon::Connection(SocketStreamTLS &rStream) { + try + { + Connection2(rStream); + } + catch(BoxException &e) + { + ::syslog(LOG_ERR, "%s: disconnecting due to " + "exception %s (%d/%d)", DaemonName(), + e.what(), e.GetType(), e.GetSubType()); + } + catch(std::exception &e) + { + ::syslog(LOG_ERR, "%s: disconnecting due to " + "exception %s", DaemonName(), e.what()); + } + catch(...) + { + ::syslog(LOG_ERR, "%s: disconnecting due to " + "unknown exception", DaemonName()); + } +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: BackupStoreDaemon::Connection2(SocketStreamTLS &) +// Purpose: Handles a connection from bbackupd +// Created: 2006/11/12 +// +// -------------------------------------------------------------------------- +void BackupStoreDaemon::Connection2(SocketStreamTLS &rStream) +{ // Get the common name from the certificate std::string clientCommonName(rStream.GetPeerCommonName()); diff --git a/bin/bbstored/BackupStoreDaemon.h b/bin/bbstored/BackupStoreDaemon.h index 0ce6f21f..eea47284 100644 --- a/bin/bbstored/BackupStoreDaemon.h +++ b/bin/bbstored/BackupStoreDaemon.h @@ -52,7 +52,8 @@ protected: virtual void Run(); - void Connection(SocketStreamTLS &rStream); + virtual void Connection(SocketStreamTLS &rStream); + void Connection2(SocketStreamTLS &rStream); virtual const char *DaemonName() const; virtual const char *DaemonBanner() const; |