Skip to content

Commit

Permalink
snmpstats: init sigaction var and close fd in case of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Dec 27, 2017
1 parent 7c61d3f commit 0b7b291
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/modules/snmpstats/snmpstats.c
Expand Up @@ -539,6 +539,7 @@ static int spawn_sysUpTime_child(void)
LM_ERR("Ran out of memory while trying to retrieve sysUpTime. ");
LM_ERR(" kamailioSIPServiceStartTime is "
"defaulting to zero\n");
close(snmpget_fd);
return -1;
} else {
/* Make a new string containing the full path to the binary. */
Expand All @@ -559,6 +560,7 @@ static int spawn_sysUpTime_child(void)

/* We should never be able to get here, because execve() is never
* supposed to return. */
close(snmpget_fd);
free(full_path_to_snmpget);
exit(-1);
}
Expand Down Expand Up @@ -587,4 +589,4 @@ int set_snmp_community(modparam_t type, void *val)
snmp_community = (char *)val;

return 0;
}
}
3 changes: 2 additions & 1 deletion src/modules/snmpstats/sub_agent.c
Expand Up @@ -167,6 +167,7 @@ void agentx_child(int rank)
* need to be fatal however, because we can re-establish our
* connection. Therefore we set ourselves up to ignore the
* SIGPIPE. */
sigemptyset(&sigpipe_handler.sa_mask);
sigpipe_handler.sa_flags = SA_RESTART;
sigpipe_handler.sa_handler = SIG_IGN;

Expand Down Expand Up @@ -194,4 +195,4 @@ void register_with_master_agent(char *name_to_register_under)
/* Use a name we can register our agent under. */
init_snmp(name_to_register_under);
LM_DBG("** Connected to SNMPD MasterX\n");
}
}

0 comments on commit 0b7b291

Please sign in to comment.