Add to unlink path
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 15 Feb 2021 07:55:26 +0000 (16:55 +0900)
committer최창규/Tizen Platform Lab(SR)/Engineer/삼성전자 <changyu.choi@samsung.com>
Mon, 15 Feb 2021 08:20:53 +0000 (17:20 +0900)
This patch adds to unlink path
when path is already used.

Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/common/socket/server_socket.cc

index ee1d7b9..e5f674b 100644 (file)
@@ -46,8 +46,10 @@ ServerSocket::ServerSocket(std::string path) : AbstractSocket(std::move(path)) {
 
     addr_.sun_family = AF_UNIX;
     strncpy(addr_.sun_path, path_.c_str(), sizeof(addr_.sun_path));
-    if (access(path_.c_str(), F_OK) == 0)
+    if (access(path_.c_str(), F_OK) == 0) {
       LOGW("socket(%s) is already used", path_.c_str());
+      unlink(path_.c_str());
+    }
 
     if (Bind() < 0) {
       LOGE("Fail to Bind server socket. errno(%d)", errno);