Skip to content

Commit

Permalink
Fixed canceling Metrics timer on FreeBSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Jan 21, 2015
1 parent 178174a commit 6d1c999
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions vm/console.cpp
Expand Up @@ -59,6 +59,8 @@ namespace rubinius {
, response_fd_(-1)
, request_exit_(false)
, response_exit_(false)
, request_running_(false)
, response_running_(false)
, request_list_(NULL)
{
shared_.auxiliary_threads()->register_thread(this);
Expand Down Expand Up @@ -112,6 +114,9 @@ namespace rubinius {
request_exit_ = false;
response_exit_ = false;

request_running_ = false;
response_running_ = false;

list_lock_.init();
response_lock_.init();
response_cond_.init();
Expand Down
20 changes: 15 additions & 5 deletions vm/metrics.cpp
Expand Up @@ -193,6 +193,7 @@ namespace rubinius {
, shared_(state->shared())
, vm_(NULL)
, thread_exit_(false)
, thread_running_(false)
, thread_(state)
, values_(state)
, interval_(state->shared().config.system_metrics_interval)
Expand Down Expand Up @@ -419,6 +420,7 @@ namespace rubinius {
void Metrics::start(STATE) {
vm_ = NULL;
thread_exit_ = false;
thread_running_ = false;

timer_ = new timer::Timer;

Expand All @@ -433,7 +435,10 @@ namespace rubinius {

atomic::memory_barrier();

if(timer_) timer_->cancel();
if(timer_) {
timer_->clear();
timer_->cancel();
}
}

void Metrics::start_thread(STATE) {
Expand All @@ -456,10 +461,11 @@ namespace rubinius {
if(vm_) {
wakeup();

pthread_t os = vm_->os_thread();

void* return_value;
pthread_join(os, &return_value);
if(atomic::poll(thread_running_, false)) {
void* return_value;
pthread_t os = vm_->os_thread();
pthread_join(os, &return_value);
}

vm_ = NULL;
}
Expand Down Expand Up @@ -492,6 +498,8 @@ namespace rubinius {
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

thread_running_ = true;

state->vm()->thread->hard_unlock(state, gct, 0);
state->gc_dependent(gct, 0);

Expand Down Expand Up @@ -549,6 +557,8 @@ namespace rubinius {

timer_->clear();

thread_running_ = false;

RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);
}
Expand Down
1 change: 1 addition & 0 deletions vm/metrics.hpp
Expand Up @@ -380,6 +380,7 @@ namespace rubinius {
SharedState& shared_;
VM* vm_;
bool thread_exit_;
bool thread_running_;

TypedRoot<Thread*> thread_;
TypedRoot<Tuple*> values_;
Expand Down

0 comments on commit 6d1c999

Please sign in to comment.