Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use lock_guard instead of lock.lock()/unlock() in Watchdog in order t…

…o avoid relocking when an unlock exception is thrown.
  • Loading branch information...
commit 476c7d114e2357fbf30f2393d66f853a2a181856 1 parent c955c2c
@FooBarWidget FooBarWidget authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 ext/common/Watchdog.cpp
View
14 ext/common/Watchdog.cpp
@@ -107,9 +107,10 @@ class AgentWatcher {
int status, e;
while (!this_thread::interruption_requested()) {
- lock.lock();
- pid = this->pid;
- lock.unlock();
+ {
+ lock_guard<boost::mutex> l(lock);
+ pid = this->pid;
+ }
// Process can be started before the watcher thread is launched.
if (pid == 0) {
@@ -132,9 +133,10 @@ class AgentWatcher {
e = errno;
}
- lock.lock();
- this->pid = 0;
- lock.unlock();
+ {
+ lock_guard<boost::mutex> l(lock);
+ this->pid = 0;
+ }
this_thread::disable_interruption di;
this_thread::disable_syscall_interruption dsi;
Please sign in to comment.
Something went wrong with that request. Please try again.