From: Dongwoo Lee Date: Thu, 10 Mar 2022 07:44:39 +0000 (+0900) Subject: monitor: request-handler: Handle negative return value of recv X-Git-Tag: accepted/tizen/unified/20220313.205607~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d3c7321774a59eb981af743b9cfa2c80df53f53;p=platform%2Fcore%2Fsystem%2Fpass.git monitor: request-handler: Handle negative return value of recv Change-Id: I4a84b3f834fbc4f036f28597aa34f0bceb9d6c5c Signed-off-by: Dongwoo Lee --- diff --git a/src/monitor/request-handler.c b/src/monitor/request-handler.c index c27e544..2fdd58a 100644 --- a/src/monitor/request-handler.c +++ b/src/monitor/request-handler.c @@ -306,15 +306,21 @@ static int request_handler_func(void *data, void **result) len = recv(client->socket_fd, buffer, REQUEST_BUFFER_MAX, 0); if (len == 0) { _D("Client-%d is disconnected", client->socket_fd); - finalize_request_client(client); - close(client->socket_fd); - destroy_request_client(client); - return THREAD_RETURN_DONE; + goto out; + } + + if (len < 0) { + _E("Error occurs while receiving request: %s", strerror(errno)); + goto out; } buffer[len] = '\0'; handle_request(client, buffer); } +out: + finalize_request_client(client); + close(client->socket_fd); + destroy_request_client(client); return THREAD_RETURN_DONE; }