[sr-dev] git:4.2:6495f412: evapi: use internal log functions and free io struct if client failed to connect

Daniel-Constantin Mierla miconda at gmail.com
Tue May 19 09:32:20 CEST 2015


Module: kamailio
Branch: 4.2
Commit: 6495f4120a702bd852c11d3449467e5ee0994bf7
URL: https://github.com/kamailio/kamailio/commit/6495f4120a702bd852c11d3449467e5ee0994bf7

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-05-19T09:26:12+02:00

evapi: use internal log functions and free io struct if client failed to connect

(cherry picked from commit eb889f41f036afb4248303fd6a1c7db393724c58)

---

Modified: modules/evapi/evapi_dispatch.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6495f4120a702bd852c11d3449467e5ee0994bf7.diff
Patch: https://github.com/kamailio/kamailio/commit/6495f4120a702bd852c11d3449467e5ee0994bf7.patch

---

diff --git a/modules/evapi/evapi_dispatch.c b/modules/evapi/evapi_dispatch.c
index 1ba1c0b..3029d77 100644
--- a/modules/evapi/evapi_dispatch.c
+++ b/modules/evapi/evapi_dispatch.c
@@ -332,12 +332,13 @@ void evapi_accept_client(struct ev_loop *loop, struct ev_io *watcher, int revent
 	
 	evapi_client = (struct ev_io*) malloc (sizeof(struct ev_io));
 	if(evapi_client==NULL) {
-		perror("no more memory\n");
+		LM_ERR("no more memory\n");
 		return;
 	}
 
 	if(EV_ERROR & revents) {
-		perror("received invalid event\n");
+		LM_ERR("received invalid event\n");
+		free(evapi_client);
 		return;
 	}
 
@@ -346,6 +347,7 @@ void evapi_accept_client(struct ev_loop *loop, struct ev_io *watcher, int revent
 
 	if (csock < 0) {
 		LM_ERR("cannot accept the client\n");
+		free(evapi_client);
 		return;
 	}
 	for(i=0; i<EVAPI_MAX_CLIENTS; i++) {
@@ -357,6 +359,7 @@ void evapi_accept_client(struct ev_loop *loop, struct ev_io *watcher, int revent
 							EVAPI_IPADDR_SIZE)==NULL) {
 					LM_ERR("cannot convert ipv4 address\n");
 					close(csock);
+					free(evapi_client);
 					return;
 				}
 			} else {
@@ -366,6 +369,7 @@ void evapi_accept_client(struct ev_loop *loop, struct ev_io *watcher, int revent
 							EVAPI_IPADDR_SIZE)==NULL) {
 					LM_ERR("cannot convert ipv6 address\n");
 					close(csock);
+					free(evapi_client);
 					return;
 				}
 			}
@@ -378,6 +382,7 @@ void evapi_accept_client(struct ev_loop *loop, struct ev_io *watcher, int revent
 	if(i==EVAPI_MAX_CLIENTS) {
 		LM_ERR("too many clients\n");
 		close(csock);
+		free(evapi_client);
 		return;
 	}
 
@@ -389,8 +394,10 @@ void evapi_accept_client(struct ev_loop *loop, struct ev_io *watcher, int revent
 	evenv.eset = 1;
 	evapi_run_cfg_route(&evenv, _evapi_rts.con_new);
 
-	if(_evapi_clients[i].connected == 0)
+	if(_evapi_clients[i].connected == 0) {
+		free(evapi_client);
 		return;
+	}
 
 	/* start watcher to read messages from whatchers */
 	ev_io_init(evapi_client, evapi_recv_client, csock, EV_READ);




More information about the sr-dev mailing list