fix race in Future::waitWithSemaphore
authorMatt Dordal <mnd@fb.com>
Wed, 17 Sep 2014 23:52:03 +0000 (16:52 -0700)
committerDave Watson <davejwatson@fb.com>
Thu, 18 Sep 2014 16:44:54 +0000 (09:44 -0700)
commit079e4ffe2f7d109c68bb66d7455d90724d7047fc
treead9d57191cad0168e5d047777702e369289ce146
parent546bd3f5f2ed1fdf3a0f5c2b6737a20c4bc2f561
fix race in Future::waitWithSemaphore

Summary:
There's a race condition in waitWithSemaphore, specifically because we're
returning a new future that's completed by the input future. As a result,
that future may not be completed by the time waitWithSemaphore returns,
although completion should be imminent.

Test Plan:
`var=0; while true ; do echo $((var++)); _bin/folly/wangle/wangle-test --gtest_filter='Future*' || break ; done`

Before change two runs yielded 303 and 371.

After change I killed the test at 11000.

Reviewed By: njormrod@fb.com

Subscribers: fugalh, njormrod

FB internal diff: D1561281

Tasks: 5180879
folly/wangle/Future-inl.h