From 51e27e29c89d51d55b08ec916f5a018bd1315058 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sun, 16 Dec 2007 08:25:57 +0000 Subject: [PATCH] * Properly clean up SCGI on exceptions so it deletes the socket file. Found by Josef Drexler. * Handle mtime properly in resume_save. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1020 e378c898-3ddf-0310-93e7-cc216c733640 --- src/control.cc | 9 ++++++++- src/control.h | 1 + src/main.cc | 7 +------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/control.cc b/src/control.cc index 86a3fce2..96db15a1 100644 --- a/src/control.cc +++ b/src/control.cc @@ -123,7 +123,7 @@ Control::initialize() { void Control::cleanup() { - delete m_scgi; m_scgi = NULL; + delete m_scgi; m_scgi = NULL; rpc::xmlrpc.cleanup(); priority_queue_erase(&taskScheduler, &m_taskShutdown); @@ -141,6 +141,13 @@ Control::cleanup() { display::Canvas::cleanup(); } +void +Control::cleanup_exception() { + delete m_scgi; m_scgi = NULL; + + display::Canvas::cleanup(); +} + void Control::handle_shutdown() { if (!m_shutdownQuick) { diff --git a/src/control.h b/src/control.h index 356dcf68..066fb996 100644 --- a/src/control.h +++ b/src/control.h @@ -81,6 +81,7 @@ public: void initialize(); void cleanup(); + void cleanup_exception(); void handle_shutdown(); diff --git a/src/main.cc b/src/main.cc index 84f9d4bb..b8c17abf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -272,15 +272,10 @@ main(int argc, char** argv) { } control->core()->download_list()->session_save(); - control->cleanup(); } catch (std::exception& e) { - display::Canvas::cleanup(); - - // Safe to delete here? Seem to cause problems if cleanup hasn't - // been called. - //delete control; + control->cleanup_exception(); std::cout << "rtorrent: " << e.what() << std::endl; return -1;