diff options
Diffstat (limited to 'tools/storage_mon.c')
-rw-r--r-- | tools/storage_mon.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/storage_mon.c b/tools/storage_mon.c index 1aae29e..a9227ef 100644 --- a/tools/storage_mon.c +++ b/tools/storage_mon.c @@ -382,9 +382,11 @@ static int write_pid_file(const char *pidfile) syslog(LOG_ERR, "Failed to write '%s' to %s: %s", pid, pidfile, strerror(errno)); goto done; } - close(fd); rc = 0; done: + if (fd != -1) { + close(fd); + } if (pid != NULL) { free(pid); } @@ -653,6 +655,7 @@ storage_mon_client(void) int32_t rc; + memset(&response, 0, sizeof(response)); snprintf(ipcs_name, SMON_MAX_IPCSNAME, "storage_mon_%s", attrname); conn = qb_ipcc_connect(ipcs_name, 0); if (conn == NULL) { @@ -663,6 +666,7 @@ storage_mon_client(void) snprintf(request.message, SMON_MAX_MSGSIZE, "%s", SMON_GET_RESULT_COMMAND); request.hdr.id = 0; request.hdr.size = sizeof(struct storage_mon_check_value_req); + response.hdr.id = 0; rc = qb_ipcc_send(conn, &request, request.hdr.size); if (rc < 0) { syslog(LOG_ERR, "qb_ipcc_send error : %d\n", rc); @@ -683,7 +687,11 @@ storage_mon_client(void) /* greater than 0 : monitoring error. */ /* -1 : communication system error. */ /* -2 : Not all checks completed for first device in daemon mode. */ - rc = atoi(response.message); + if (strnlen(response.message, 1)) { + rc = atoi(response.message); + } else { + rc = -1; + } syslog(LOG_DEBUG, "daemon response[%d]: %s \n", response.hdr.id, response.message); |