Fix critical section range 50/305150/1
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 29 Jan 2024 09:37:37 +0000 (18:37 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Mon, 29 Jan 2024 09:37:37 +0000 (18:37 +0900)
lock should be get before checking whether listener_ is nullptr or not.

Change-Id: Ied8d03d9bc772542837d7f8b5f2eb1ad8a61c5e9
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/stub-internal.cc

index 0abc27d..d968ff9 100644 (file)
@@ -111,12 +111,12 @@ int Stub::Listen(IEventListener* ev, int fd) {
   if (ev == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
+  std::lock_guard<std::recursive_mutex> lock(GetMutex());
   if (listener_ != nullptr) {
     _E("Already listening!");  // LCOV_EXCL_LINE
     return RPC_PORT_ERROR_INVALID_PARAMETER;  // LCOV_EXCL_LINE
   }
 
-  std::lock_guard<std::recursive_mutex> lock(GetMutex());
   listener_ = ev;
   server_.reset(new Server(fd, this));
   return server_->Listen();