@@ -102,6 +102,7 @@ void Watchdog::Timer(uv_timer_t* timer) { |
102 | 102 | SigintWatchdog::SigintWatchdog( |
103 | 103 | v8::Isolate* isolate, bool* received_signal) |
104 | 104 | : isolate_(isolate), received_signal_(received_signal) { |
| 105 | + Mutex::ScopedLock lock(SigintWatchdogHelper::GetInstanceActionMutex()); |
105 | 106 | // Register this watchdog with the global SIGINT/Ctrl+C listener. |
106 | 107 | SigintWatchdogHelper::GetInstance()->Register(this); |
107 | 108 | // Start the helper thread, if that has not already happened. |
@@ -110,6 +111,7 @@ SigintWatchdog::SigintWatchdog( |
110 | 111 |
|
111 | 112 |
|
112 | 113 | SigintWatchdog::~SigintWatchdog() { |
| 114 | + Mutex::ScopedLock lock(SigintWatchdogHelper::GetInstanceActionMutex()); |
113 | 115 | SigintWatchdogHelper::GetInstance()->Unregister(this); |
114 | 116 | SigintWatchdogHelper::GetInstance()->Stop(); |
115 | 117 | } |
@@ -144,6 +146,7 @@ void TraceSigintWatchdog::New(const FunctionCallbackInfo<Value>& args) { |
144 | 146 | void TraceSigintWatchdog::Start(const FunctionCallbackInfo<Value>& args) { |
145 | 147 | TraceSigintWatchdog* watchdog; |
146 | 148 | ASSIGN_OR_RETURN_UNWRAP(&watchdog, args.Holder()); |
| 149 | + Mutex::ScopedLock lock(SigintWatchdogHelper::GetInstanceActionMutex()); |
147 | 150 | // Register this watchdog with the global SIGINT/Ctrl+C listener. |
148 | 151 | SigintWatchdogHelper::GetInstance()->Register(watchdog); |
149 | 152 | // Start the helper thread, if that has not already happened. |
@@ -154,6 +157,7 @@ void TraceSigintWatchdog::Start(const FunctionCallbackInfo<Value>& args) { |
154 | 157 | void TraceSigintWatchdog::Stop(const FunctionCallbackInfo<Value>& args) { |
155 | 158 | TraceSigintWatchdog* watchdog; |
156 | 159 | ASSIGN_OR_RETURN_UNWRAP(&watchdog, args.Holder()); |
| 160 | + Mutex::ScopedLock lock(SigintWatchdogHelper::GetInstanceActionMutex()); |
157 | 161 | SigintWatchdogHelper::GetInstance()->Unregister(watchdog); |
158 | 162 | SigintWatchdogHelper::GetInstance()->Stop(); |
159 | 163 | } |
@@ -215,6 +219,7 @@ void TraceSigintWatchdog::HandleInterrupt() { |
215 | 219 | signal_flag_ = SignalFlags::None; |
216 | 220 | interrupting = false; |
217 | 221 |
|
| 222 | + Mutex::ScopedLock lock(SigintWatchdogHelper::GetInstanceActionMutex()); |
218 | 223 | SigintWatchdogHelper::GetInstance()->Unregister(this); |
219 | 224 | SigintWatchdogHelper::GetInstance()->Stop(); |
220 | 225 | raise(SIGINT); |
@@ -413,6 +418,7 @@ SigintWatchdogHelper::~SigintWatchdogHelper() { |
413 | 418 | } |
414 | 419 |
|
415 | 420 | SigintWatchdogHelper SigintWatchdogHelper::instance; |
| 421 | +Mutex SigintWatchdogHelper::instance_action_mutex_; |
416 | 422 |
|
417 | 423 | namespace watchdog { |
418 | 424 | static void Initialize(Local<Object> target, |
|