Module: kamailio Branch: master Commit: eb889f41f036afb4248303fd6a1c7db393724c58 URL: https://github.com/kamailio/kamailio/commit/eb889f41f036afb4248303fd6a1c7db3...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2015-05-13T16:05:09+02:00
evapi: use internal log functions and free io struct if client failed to connect
---
Modified: modules/evapi/evapi_dispatch.c
---
Diff: https://github.com/kamailio/kamailio/commit/eb889f41f036afb4248303fd6a1c7db3... Patch: https://github.com/kamailio/kamailio/commit/eb889f41f036afb4248303fd6a1c7db3...
---
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);