From a9bfaf9e54fd956130552d19e99b9a876669eb36 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 30 Sep 2015 14:58:17 +0200 Subject: [PATCH] client: don't try sending request with invalid socket --- client.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 234c9b3..1dd0db8 100644 --- a/client.c +++ b/client.c @@ -1317,14 +1317,19 @@ submit_request(CMD_Request *request, CMD_Reply *reply) /* Zero the padding to avoid sending uninitialized data */ memset(((char *)request) + command_length - padding_length, 0, padding_length); + if (sock_fd < 0) { + DEBUG_LOG(LOGF_Client, "No socket to send request"); + return 0; + } + if (send(sock_fd, (void *)request, command_length, 0) < 0) { DEBUG_LOG(LOGF_Client, "Could not send %d bytes : %s", command_length, strerror(errno)); return 0; - } else { - DEBUG_LOG(LOGF_Client, "Sent %d bytes", command_length); } + DEBUG_LOG(LOGF_Client, "Sent %d bytes", command_length); + /* Increment this for next time */ ++ request->attempt;