]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: don't try sending request with invalid socket
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 30 Sep 2015 12:58:17 +0000 (14:58 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 30 Sep 2015 12:58:17 +0000 (14:58 +0200)
client.c

index 234c9b318df2c0ecea8315a57c9450bbcdaf0540..1dd0db8e663f41cfade52269cda46f27f8ba5bac 100644 (file)
--- 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;