The rpc-port library can be loaded and unloaded using dlopen() and
dlclose() in the runtime. In this case, the process has crashed by
the thread of the rpc-port library. Before unloading the library, the thread
has to be terminated. This patch uses destructor attribute to terminate
the thread appropriately before unloading the library is finished.
Change-Id: I2338a4419f02fb67dff042fd308ba1d590bf0ac3
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
#include "debug-port-internal.hh"
#include "log-private.hh"
+#undef RPC_DTOR
+#define RPC_DTOR __attribute__ ((destructor))
+
namespace rpc_port {
namespace internal {
namespace {
const char PATH_RPC_PORT_UTIL_SOCK[] = "/run/aul/daemons/.rpc-port-util-sock";
+
+RPC_DTOR void DebugPortDtor() {
+ DebugPort::GetInst()->Dispose();
+}
+
} // namespace
std::atomic<DebugPort*> DebugPort::inst_;
std::mutex DebugPort::mutex_;
DebugPort::~DebugPort() {
- if (!disposed_)
- Dispose();
+ Dispose();
}
DebugPort* DebugPort::GetInst() {
}
void DebugPort::Dispose() {
+ std::lock_guard<std::recursive_mutex> lock(GetMutex());
+ if (disposed_)
+ return;
+
Unwatch();
JoinThread();
disposed_ = true;