client: don't try sending request with invalid socket

This commit is contained in:
Miroslav Lichvar 2015-09-30 14:58:17 +02:00
parent cec7c44f61
commit a9bfaf9e54

View file

@ -1317,14 +1317,19 @@ submit_request(CMD_Request *request, CMD_Reply *reply)
/* Zero the padding to avoid sending uninitialized data */ /* Zero the padding to avoid sending uninitialized data */
memset(((char *)request) + command_length - padding_length, 0, padding_length); 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) { if (send(sock_fd, (void *)request, command_length, 0) < 0) {
DEBUG_LOG(LOGF_Client, "Could not send %d bytes : %s", DEBUG_LOG(LOGF_Client, "Could not send %d bytes : %s",
command_length, strerror(errno)); command_length, strerror(errno));
return 0; 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 */ /* Increment this for next time */
++ request->attempt; ++ request->attempt;