From 347dabbbd68f7cb83078d2cb65989ecf082897d6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 9 May 2015 13:46:42 -0700 Subject: [PATCH] Make HandlePool resistant to reentrant calls Conpherence thread handles need to load other handles in order to load. Currently, HandlePool can loop when reentered. Instead, clear the on-deck list before querying so that reentering it will query for only new handles, not reissue queries for in-flight handles. Auditors: btrahan --- .../phid/handle/pool/PhabricatorHandlePool.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/applications/phid/handle/pool/PhabricatorHandlePool.php b/src/applications/phid/handle/pool/PhabricatorHandlePool.php index a1195225bb..eaa48828a4 100644 --- a/src/applications/phid/handle/pool/PhabricatorHandlePool.php +++ b/src/applications/phid/handle/pool/PhabricatorHandlePool.php @@ -61,12 +61,17 @@ final class PhabricatorHandlePool extends Phobject { // If we need any handles, bulk load everything in the queue. if ($need) { + // Clear the list of PHIDs that need to be loaded before performing the + // actual fetch. This prevents us from looping if we need to reenter the + // HandlePool while loading handles. + $fetch_phids = array_keys($this->unloadedPHIDs); + $this->unloadedPHIDs = array(); + $handles = id(new PhabricatorHandleQuery()) ->setViewer($this->getViewer()) - ->withPHIDs(array_keys($this->unloadedPHIDs)) + ->withPHIDs($fetch_phids) ->execute(); $this->handles += $handles; - $this->unloadedPHIDs = array(); } return array_select_keys($this->handles, $phids);