Actually manage memory in the old-style AOS logging
LeakSanitizer should be happy with it now. It's also still just as
thread-safe.
Change-Id: Id09a0349657cf4f719267b053f0ea3d8ec366256
diff --git a/aos/stl_mutex/stl_mutex.h b/aos/stl_mutex/stl_mutex.h
index 4e14557..86a5988 100644
--- a/aos/stl_mutex/stl_mutex.h
+++ b/aos/stl_mutex/stl_mutex.h
@@ -4,9 +4,8 @@
#include <mutex>
#include "aos/ipc_lib/aos_sync.h"
-#include "aos/logging/logging.h"
-#include "aos/type_traits/type_traits.h"
#include "aos/macros.h"
+#include "glog/logging.h"
namespace aos {
@@ -31,7 +30,7 @@
owner_died_ = true;
break;
default:
- AOS_LOG(FATAL, "mutex_grab(%p) failed with %d\n", &native_handle_, ret);
+ LOG(FATAL) << "mutex_grab(" << &native_handle_ << ") failed: " << ret;
}
}
@@ -46,13 +45,13 @@
case 4:
return false;
default:
- AOS_LOG(FATAL, "mutex_trylock(%p) failed with %d\n", &native_handle_,
- ret);
+ LOG(FATAL) << "mutex_trylock(" << &native_handle_
+ << ") failed: " << ret;
}
}
void unlock() {
- AOS_CHECK(!owner_died_);
+ CHECK(!owner_died_);
mutex_unlock(&native_handle_);
}
@@ -84,20 +83,20 @@
void lock() {
if (mutex_islocked(mutex_.native_handle())) {
- AOS_CHECK(!owner_died());
+ CHECK(!owner_died());
++recursive_locks_;
} else {
mutex_.lock();
if (mutex_.owner_died()) {
recursive_locks_ = 0;
} else {
- AOS_CHECK_EQ(0, recursive_locks_);
+ CHECK_EQ(0, recursive_locks_);
}
}
}
bool try_lock() {
if (mutex_islocked(mutex_.native_handle())) {
- AOS_CHECK(!owner_died());
+ CHECK(!owner_died());
++recursive_locks_;
return true;
} else {
@@ -105,7 +104,7 @@
if (mutex_.owner_died()) {
recursive_locks_ = 0;
} else {
- AOS_CHECK_EQ(0, recursive_locks_);
+ CHECK_EQ(0, recursive_locks_);
}
return true;
} else {