From d8d09559102eb73e0cfb3d3706aa074be7736a14 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 17 Oct 2008 01:47:24 +0000 Subject: [PATCH] client_test fix to not crash when loading an invalid torrent file and shut down properly (set torrents to not be auto managed when pausing them) --- examples/client_test.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 993f88181..b0ebd10f0 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -492,7 +492,15 @@ void add_torrent(libtorrent::session& ses { using namespace libtorrent; - boost::intrusive_ptr t(new torrent_info(torrent.c_str())); + boost::intrusive_ptr t; + try + { + t = new torrent_info(torrent.c_str()); + } + catch (std::exception&) + { + return; + } std::cout << t->name() << "\n"; @@ -1096,11 +1104,14 @@ int main(int ac, char* av[]) i != handles.end(); ++i) { torrent_handle& h = i->second; - if (!h.is_valid() || !h.has_metadata()) continue; + if (!h.is_valid()) continue; + h.auto_managed(false); + if (h.is_paused()) continue; + h.pause(); + if (!h.has_metadata()) continue; // pause std::cout << "pausing " << h.name() << std::endl; - h.pause(); // save_resume_data will generate an alert when it's done h.save_resume_data(); ++num_resume_data;