diff options
author | Sander Vrijders <[email protected]> | 2016-08-04 18:08:32 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-08-04 18:08:32 +0200 |
commit | d5b71449bc18116444720257ba640e3c597ff6e9 (patch) | |
tree | e2fca06805ca406607402c7206ea14ae17611d82 /src/ipcpd/ipcp.c | |
parent | 51bb7c6f315dba4044eb2ece5c1312362674d7fb (diff) | |
parent | 25c356b9ba9d91b4a291e3adad050d8ea85eb3e2 (diff) | |
download | ouroboros-d5b71449bc18116444720257ba640e3c597ff6e9.tar.gz ouroboros-d5b71449bc18116444720257ba640e3c597ff6e9.zip |
Merged in dstaesse/ouroboros/be-bugfixing (pull request #186)
Be bugfixing
Diffstat (limited to 'src/ipcpd/ipcp.c')
-rw-r--r-- | src/ipcpd/ipcp.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index fb31cf1b..9ecc411d 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -86,6 +86,16 @@ int ipcp_parse_arg(int argc, char * argv[]) return 0; } +static void close_ptr(void * o) +{ + close(*((int *) o)); +} + +static void clean_msg(void * msg) +{ + ipcp_msg__free_unpacked(msg, NULL); +} + void * ipcp_main_loop(void * o) { int lsockfd; @@ -118,11 +128,10 @@ void * ipcp_main_loop(void * o) return (void *) 1; } - pthread_cleanup_push((void(*)(void *)) close, - (void *) &sockfd); - free(sock_path); + pthread_cleanup_push(close_ptr, (void *) &sockfd); + while (true) { ret_msg.code = IPCP_MSG_CODE__IPCP_REPLY; @@ -145,6 +154,8 @@ void * ipcp_main_loop(void * o) continue; } + pthread_cleanup_push(clean_msg, (void *) msg); + switch (msg->code) { case IPCP_MSG_CODE__IPCP_BOOTSTRAP: if (_ipcp->ops->ipcp_bootstrap == NULL) { @@ -170,9 +181,8 @@ void * ipcp_main_loop(void * o) conf.dns_addr = conf_msg->dns_addr; } - if (conf_msg->ipcp_type == IPCP_SHIM_ETH_LLC) { + if (conf_msg->ipcp_type == IPCP_SHIM_ETH_LLC) conf.if_name = conf_msg->if_name; - } ret_msg.has_result = true; ret_msg.result = _ipcp->ops->ipcp_bootstrap(&conf); @@ -193,7 +203,8 @@ void * ipcp_main_loop(void * o) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_name_reg(msg->name); + ret_msg.result = + _ipcp->ops->ipcp_name_reg(strdup(msg->name)); break; case IPCP_MSG_CODE__IPCP_NAME_UNREG: if (_ipcp->ops->ipcp_name_unreg == NULL) { @@ -201,7 +212,8 @@ void * ipcp_main_loop(void * o) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_name_unreg(msg->name); + ret_msg.result = + _ipcp->ops->ipcp_name_unreg(msg->name); break; case IPCP_MSG_CODE__IPCP_FLOW_ALLOC: if (_ipcp->ops->ipcp_flow_alloc == NULL) { @@ -241,7 +253,8 @@ void * ipcp_main_loop(void * o) break; } - ipcp_msg__free_unpacked(msg, NULL); + pthread_cleanup_pop(true); + buffer.len = ipcp_msg__get_packed_size(&ret_msg); if (buffer.len == 0) { @@ -265,10 +278,10 @@ void * ipcp_main_loop(void * o) } free(buffer.data); - close(lsockfd); + } - pthread_cleanup_pop(0); + pthread_cleanup_pop(true); return NULL; } |