Add to destruct job for release callbacks
authorChanggyu Choi <changyu.choi@samsung.com>
Thu, 18 Feb 2021 09:27:50 +0000 (18:27 +0900)
committer최창규/Tizen Platform Lab(SR)/Engineer/삼성전자 <changyu.choi@samsung.com>
Fri, 19 Feb 2021 00:58:13 +0000 (09:58 +0900)
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/server/runner.cc
src/server/runner.hh

index 50b7320..fb7afa0 100644 (file)
@@ -32,15 +32,20 @@ namespace pkgmgr_server {
 
 static const std::string SOCK_PATH = "/run/pkgmgr-info-server";
 
-Runner::Runner(int thread_num) : thread_num_(thread_num) {
+Runner::Runner(int thread_num) : sid_(-1), thread_num_(thread_num) {
   server_ = std::make_unique<pkgmgr_common::socket::ServerSocket>(SOCK_PATH);
   thread_pool_ = std::make_unique<WorkerThread>(thread_num_);
-  g_unix_fd_add(server_->GetFd(), G_IO_IN, OnReceiveRequest, this);
+  sid_ = g_unix_fd_add(server_->GetFd(), G_IO_IN, OnReceiveRequest, this);
   vconf_notify_key_changed(VCONFKEY_LANGSET, OnLanguageChange, this);
   thread_pool_->SetLocale(vconf_get_str(VCONFKEY_LANGSET));
   LOGI("Start Runner");
 }
 
+Runner::~Runner() {
+  g_source_remove(sid_);
+  vconf_ignore_key_changed(VCONFKEY_LANGSET, OnLanguageChange);
+}
+
 int Runner::OnReceiveRequest(int fd, GIOCondition cond, void* user_data) {
   auto runner = static_cast<Runner*>(user_data);
   int client_fd = runner->server_->Accept();
index b584259..52ba888 100644 (file)
@@ -34,7 +34,7 @@ namespace pkgmgr_server {
 class EXPORT_API Runner {
  public:
   Runner(int thread_num);
-  ~Runner() = default;
+  ~Runner();
 
  private:
   static int OnReceiveRequest(int fd, GIOCondition cond, void* user_data);
@@ -42,6 +42,7 @@ class EXPORT_API Runner {
   bool QueueRequest(int client_fd);
 
  private:
+  int sid_;
   int thread_num_;
   std::unique_ptr<pkgmgr_common::socket::ServerSocket> server_;
   std::unique_ptr<WorkerThread> thread_pool_;