Fix unsynchronized accesses in IOThreadPoolExecutor::getEventBase
authorYedidya Feldblum <yfeldblum@fb.com>
Wed, 1 Nov 2017 21:11:27 +0000 (14:11 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 1 Nov 2017 21:17:59 +0000 (14:17 -0700)
commit6e142c0d2361e9be62b494509a5339237317cf11
treef8c913f6e052f63f869791470075967fa7b01ad6
parent9216d96a454d5e9b51873bda5e56ec7b085d4bbe
Fix unsynchronized accesses in IOThreadPoolExecutor::getEventBase

Summary:
[Folly] Fix unsynchronized accesses in `IOThreadPoolExecutor::getEventBase`.

`getEventBase` may be invoked concurrently from two threads - RMWs to `nextThread_` must be synchronized with each other.

`getEventBase` may be invoked concurrently with `setNumThreads` - the former's reads of `threadList_.vec_` must be synchronized with the latter's writes to it.

Reviewed By: kennyyu

Differential Revision: D6206916

fbshipit-source-id: 8bfae158effb5896ab478d0c20310293b037c892
folly/executors/IOThreadPoolExecutor.cpp
folly/executors/IOThreadPoolExecutor.h