Skip to content

Commit

Permalink
Fix race condition in ProcessMonitor
Browse files Browse the repository at this point in the history
If any new external process was enabled/disabled during
the process monitoring loop time, a RuntimeError: dictionary
changed size during iteration was thrown. This is fixed
by pre-building the service list from the dictionary
for the iteration.

Closes-Bug: #1401042

Change-Id: Id0a3af22fb85992bde35d8c691bee3ddf435639d
  • Loading branch information
Miguel Angel Ajo committed Dec 11, 2014
1 parent 988bd65 commit b25915f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion neutron/agent/linux/external_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ def _spawn_checking_thread(self):

@lockutils.synchronized("_check_child_processes")
def _check_child_processes(self):
for service_id in self._process_managers:
# we build the list of keys before iterating in the loop to cover
# the case where other threads add or remove items from the
# dictionary which otherwise will cause a RuntimeError
for service_id in list(self._process_managers):
pm = self._process_managers.get(service_id)

if pm and not pm.active:
Expand Down

0 comments on commit b25915f

Please sign in to comment.