From 2ed2d479c67c425a255f8991aa72df3ff4780d48 Mon Sep 17 00:00:00 2001 From: subtly Date: Sun, 5 Oct 2014 19:48:08 +0200 Subject: [PATCH] Add mutexed askedContains in placed of .asked.contains(). Issue #333 (dev::RangeMask::contains), nextFetch clears m_asked concurrent to m_asked.contains() iteration. --- alethzero/DownloadView.cpp | 2 +- libethereum/DownloadMan.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/alethzero/DownloadView.cpp b/alethzero/DownloadView.cpp index 56dd9c3d2..a6533023c 100644 --- a/alethzero/DownloadView.cpp +++ b/alethzero/DownloadView.cpp @@ -63,7 +63,7 @@ void DownloadView::paintEvent(QPaintEvent*) unsigned h = 0; m_man->foreachSub([&](DownloadSub const& sub) { - if (sub.asked().contains(i)) + if (sub.askedContains(i)) s = h; h++; }); diff --git a/libethereum/DownloadMan.h b/libethereum/DownloadMan.h index 3bd401d8e..6f4c4bafb 100644 --- a/libethereum/DownloadMan.h +++ b/libethereum/DownloadMan.h @@ -54,6 +54,7 @@ public: /// Nothing doing here. void doneFetch() { resetFetch(); } + bool askedContains(unsigned _i) const { Guard l(m_fetch); return m_asked.contains(_i); } RangeMask const& asked() const { return m_asked; } RangeMask const& attemped() const { return m_attempted; } @@ -69,7 +70,7 @@ private: DownloadMan* m_man = nullptr; - Mutex m_fetch; + mutable Mutex m_fetch; h256Set m_remaining; std::map m_indices; RangeMask m_asked;