Skip to content

Commit

Permalink
Lock when calling Console::stop_threads().
Browse files Browse the repository at this point in the history
When calling this method (e.g. when forking) there would be a very small time
frame where a read() call in FSEvent could be called _before_ the exit-request
status was set. This would result in a console thread hanging forever in a
read() call as everything else was already shut down (by the looks of it).

The solution here is to lock before we set the status and perform any cleanup
tasks.

This fixes #3121 #3129.
Yorick Peterse committed Sep 21, 2014
1 parent 6e97298 commit 646b214
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions vm/console.cpp
Original file line number Diff line number Diff line change
@@ -188,6 +188,13 @@ namespace rubinius {
SYNC(state);

if(request_vm_) {
file::LockGuard guard(request_fd_, LOCK_EX);

if(guard.status() == file::eLockSucceeded) {

This comment has been minimized.

Copy link
@yorickpeterse

yorickpeterse Sep 21, 2014

Contributor

Fuck, I'm a dumbass. This is supposed to be guard.status() != .....

logger::error("%s: console: unable to lock request file", strerror(errno));
return;
}

wakeup();

pthread_t os = request_vm_->os_thread();
@@ -200,6 +207,13 @@ namespace rubinius {
}

if(response_vm_) {
file::LockGuard guard(response_fd_, LOCK_EX);

if(guard.status() != file::eLockSucceeded) {
logger::error("%s: unable to lock response file", strerror(errno));
return;
}

pthread_t os = response_vm_->os_thread();
response_exit_ = true;

0 comments on commit 646b214

Please sign in to comment.