Skip to content

Commit

Permalink
Switched fork/exec lock to SpinLock.
Browse files Browse the repository at this point in the history
Since a SpinLock is a simple integer on which CAS operations are performed,
there is no way to go afoul of 'ownership' during fork(). This appears to
solve a spordic issue where the child was not able to reset the fork_exec_lock_
inherited from the parent process.
  • Loading branch information
brixen committed Mar 19, 2016
1 parent 9524ae1 commit 154bde3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions machine/builtin/system.cpp
Expand Up @@ -382,7 +382,7 @@ namespace rubinius {
}

static int fork_exec(STATE, int errors_fd) {
utilities::thread::Mutex::LockGuard guard(state->shared().fork_exec_lock());
utilities::thread::SpinLock::LockGuard guard(state->shared().fork_exec_lock());

state->shared().internal_threads()->before_fork_exec(state);

Expand Down Expand Up @@ -675,7 +675,7 @@ namespace rubinius {
}

Object* System::vm_exec(STATE, String* path, Array* args) {
utilities::thread::Mutex::LockGuard guard(state->shared().fork_exec_lock());
utilities::thread::SpinLock::LockGuard guard(state->shared().fork_exec_lock());

/* Setting up the command and arguments may raise an exception so do it
* before everything else.
Expand Down Expand Up @@ -817,7 +817,7 @@ namespace rubinius {
int pid = -1;

{
utilities::thread::Mutex::LockGuard guard(state->shared().fork_exec_lock());
utilities::thread::SpinLock::LockGuard guard(state->shared().fork_exec_lock());

state->shared().internal_threads()->before_fork(state);

Expand Down
4 changes: 2 additions & 2 deletions machine/shared_state.cpp
Expand Up @@ -46,8 +46,8 @@ namespace rubinius {
, root_vm_(0)
, env_(env)
, tool_broker_(new tooling::ToolBroker)
, fork_exec_lock_()
, codedb_lock_(true)
, fork_exec_lock_()
, capi_ds_lock_()
, capi_locks_lock_()
, capi_constant_lock_()
Expand Down Expand Up @@ -160,8 +160,8 @@ namespace rubinius {

// Reinit the locks for this object
global_cache->reset();
fork_exec_lock_.init();
codedb_lock_.init(true);
fork_exec_lock_.init();
capi_ds_lock_.init();
capi_locks_lock_.init();
capi_constant_lock_.init();
Expand Down
4 changes: 2 additions & 2 deletions machine/shared_state.hpp
Expand Up @@ -106,9 +106,9 @@ namespace rubinius {
Environment* env_;
tooling::ToolBroker* tool_broker_;

utilities::thread::Mutex fork_exec_lock_;
utilities::thread::Mutex codedb_lock_;

utilities::thread::SpinLock fork_exec_lock_;
utilities::thread::SpinLock capi_ds_lock_;
utilities::thread::SpinLock capi_locks_lock_;
utilities::thread::SpinLock capi_constant_lock_;
Expand Down Expand Up @@ -268,7 +268,7 @@ namespace rubinius {

const unsigned int* object_memory_mark_address() const;

utilities::thread::Mutex& fork_exec_lock() {
utilities::thread::SpinLock& fork_exec_lock() {
return fork_exec_lock_;
}

Expand Down

0 comments on commit 154bde3

Please sign in to comment.