GitHub user tpcwang opened a pull request:
https://github.com/apache/thrift/pull/959
THRIFT-3753 Fixed a race condition in TServerFramework::stop that prevents
clean server shutdown
This is a sequence that exposes the race condition:
(1) Thread-1: in serve(), blocked on accept()
(2) Thread-2: in stop(), calls interrupt()
(3) Thread-2: in stop(), in interruptChildren(), checked that socket is
valid
(4) Thread-1: in serve(), unblocked because of interrupt(), calls
releaseOneDescriptor
(5) Thread-2: in interruptChildren(), send fails so clients are not
interrupted
Closing a socket while it is being polled/selected may or may not work on
all platforms, so I think changing the order is better.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/tpcwang/thrift THRIFT-3753
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/959.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #959
----
commit 712df0e1473b56909e8f4a393fe64607f4493a47
Author: tpcwang <[email protected]>
Date: 2016-03-23T19:20:44Z
Fixed a race condition in TServerFramework::stop that prevents clean server
shutdown.
This is a sequence that exposes the race condition:
(1) Thread-1: in serve(), blocked on accept()
(2) Thread-2: in stop(), calls interrupt()
(3) Thread-2: in stop(), in interruptChildren(), checked that socket is
valid
(4) Thread-1: in serve(), unblocked because of interrupt(), calls
releaseOneDescriptor
(5) Thread-2: in interruptChildren(), send fails so clients are not
interrupted
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---