[sr-dev] git:master:f75eba63: statsd: simplified error handling inside statsd_connect()
Daniel-Constantin Mierla
miconda at gmail.com
Mon Jul 24 11:50:36 CEST 2017
Module: kamailio
Branch: master
Commit: f75eba63a1f0176adc8cd38846a0d1943471e10c
URL: https://github.com/kamailio/kamailio/commit/f75eba63a1f0176adc8cd38846a0d1943471e10c
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-24T11:44:21+02:00
statsd: simplified error handling inside statsd_connect()
---
Modified: src/modules/statsd/lib_statsd.c
---
Diff: https://github.com/kamailio/kamailio/commit/f75eba63a1f0176adc8cd38846a0d1943471e10c.diff
Patch: https://github.com/kamailio/kamailio/commit/f75eba63a1f0176adc8cd38846a0d1943471e10c.patch
---
diff --git a/src/modules/statsd/lib_statsd.c b/src/modules/statsd/lib_statsd.c
index bbda181d6a..79d99fcfbd 100644
--- a/src/modules/statsd/lib_statsd.c
+++ b/src/modules/statsd/lib_statsd.c
@@ -29,25 +29,24 @@ bool statsd_connect(void){
rc = getaddrinfo(
statsd_connection.ip, statsd_connection.port,
NULL, &serverAddr);
- if (rc != 0)
+ if (rc != 0 || serverAddr == NULL)
{
- LM_ERR(
- "Statsd: could not initiate server information (%s)\n",
+ LM_ERR("Statsd: could not initiate server information (%s)\n",
gai_strerror(rc));
- if(serverAddr) freeaddrinfo(serverAddr);
+ if(serverAddr) freeaddrinfo(serverAddr);
return false;
}
statsd_connection.sock = socket(serverAddr->ai_family, SOCK_DGRAM, IPPROTO_UDP);
if (statsd_connection.sock < 0 ){
LM_ERR("Statsd: could not create a socket for statsd connection\n");
- if(serverAddr) freeaddrinfo(serverAddr);
+ freeaddrinfo(serverAddr);
return false;
}
- rc = connect(
- statsd_connection.sock, serverAddr->ai_addr, serverAddr->ai_addrlen);
- freeaddrinfo(serverAddr);
+ rc = connect(statsd_connection.sock, serverAddr->ai_addr,
+ serverAddr->ai_addrlen);
+ freeaddrinfo(serverAddr);
if (rc < 0){
LM_ERR("Statsd: could not initiate a connect to statsd\n");
return false;
More information about the sr-dev
mailing list