From: Sarang Masti Date: Tue, 28 Nov 2017 23:51:10 +0000 (-0800) Subject: Fix incorrect usages of folly::Synchronized X-Git-Tag: v2017.12.04.00~25 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=ecb501b7f5c77cf3aff3603b22040824ae766b75;hp=d017a3ffa0acf3389a1ee585a035c01cd9e51d07 Fix incorrect usages of folly::Synchronized Summary: We need to keep LockedPtr returned by rlock/wlock alive for the entire duration of the loop. Else we are working on a snapshot of the data structure, which might not be what we want. Reviewed By: aary, ot, luciang Differential Revision: D6426613 fbshipit-source-id: 294c0a7b9d756f3116d5cdb3a7b3678f693e0754 --- diff --git a/folly/io/async/EventBaseLocal.cpp b/folly/io/async/EventBaseLocal.cpp index cda63113..c754ae7f 100644 --- a/folly/io/async/EventBaseLocal.cpp +++ b/folly/io/async/EventBaseLocal.cpp @@ -22,7 +22,8 @@ namespace folly { namespace detail { EventBaseLocalBase::~EventBaseLocalBase() { - for (auto* evb : *eventBases_.rlock()) { + auto locked = eventBases_.rlock(); + for (auto* evb : *locked) { evb->runInEventBaseThread([ this, evb, key = key_ ] { evb->localStorage_.erase(key); evb->localStorageToDtor_.erase(this);