From 9e0d4de2aa01f4e1f015c8a1df2797523e575c70 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Mon, 21 Dec 2015 12:01:55 +0900 Subject: [PATCH] sensord: close socket fd if accept() is failed Change-Id: I93093632a3f9bcbcbcf4007564bb6c7d9512bd7a Signed-off-by: kibak.yoon --- src/shared/csocket.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shared/csocket.cpp b/src/shared/csocket.cpp index 9d80138..5fbb2c1 100644 --- a/src/shared/csocket.cpp +++ b/src/shared/csocket.cpp @@ -154,8 +154,10 @@ bool csocket::accept(csocket& client_socket) const do { client_socket.m_sock_fd = ::accept(m_sock_fd, (sockaddr *)&m_addr, (socklen_t *)&addr_length); - if (!client_socket.is_valid()) + if (!client_socket.is_valid()) { err = errno; + ::close(client_socket.m_sock_fd); + } } while (err == EINTR); if (!client_socket.is_valid()) { -- 2.7.4