From 3df15ad39e1f2bce6c991eb5133555e6ec3c58ba Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 14 Jun 2009 22:48:07 +0000 Subject: [PATCH] fixed memory leak in disk io thread when not using the cache --- ChangeLog | 1 + src/disk_io_thread.cpp | 1 + test/test_web_seed.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f94b847dc..944b1e229 100644 --- a/ChangeLog +++ b/ChangeLog @@ -61,6 +61,7 @@ release 0.14.5 * fixed bug when handling malformed webseed urls and an http proxy * fixed bug when setting unlimited upload or download rates for torrents * fix to make torrent_status::list_peers more accurate. + * fixed memory leak in disk io thread when not using the cache release 0.14.4 diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 6225f28b3..af8192ffd 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1608,6 +1608,7 @@ namespace libtorrent test_error(j); break; } + break; } } // we've now inserted the buffer diff --git a/test/test_web_seed.cpp b/test/test_web_seed.cpp index a17c08646..4587449e3 100644 --- a/test/test_web_seed.cpp +++ b/test/test_web_seed.cpp @@ -88,6 +88,8 @@ void test_transfer(boost::intrusive_ptr torrent_file, int proxy) float rate_sum = 0.f; float ses_rate_sum = 0.f; + cache_status cs; + for (int i = 0; i < 30; ++i) { torrent_status s = th.status(); @@ -95,7 +97,7 @@ void test_transfer(boost::intrusive_ptr torrent_file, int proxy) rate_sum += s.download_payload_rate; ses_rate_sum += ss.payload_download_rate; - cache_status cs = ses.get_cache_status(); + cs = ses.get_cache_status(); if (cs.blocks_read < 1) cs.blocks_read = 1; if (cs.blocks_written < 1) cs.blocks_written = 1; @@ -121,6 +123,9 @@ void test_transfer(boost::intrusive_ptr torrent_file, int proxy) test_sleep(1000); } + TEST_CHECK(cs.cache_size == 0); + TEST_CHECK(cs.total_used_buffers == 0); + std::cerr << "total_size: " << total_size << " rate_sum: " << rate_sum << " session_rate_sum: " << ses_rate_sum