From 0a522059164165822bcf6a212763742f3c72bbbc Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Thu, 24 Mar 2011 10:38:01 +0100 Subject: [PATCH] [Listener] Use pthread_cleanup* --- owlps-listener/owlps-listenerd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index 032bc45..13c2b85 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -1043,6 +1043,7 @@ void* autocalibrate_hello(void *NULL_value) owlclient_create_trx_socket(GET_AGGREGATION_IP(), GET_AUTOCALIBRATION_PORT(), &serv, NULL) ; + pthread_cleanup_push(&owl_close_fd, &send_sockfd) ; memcpy(&message.ap_mac_addr_bytes, my_mac_bytes, 6) ; @@ -1053,7 +1054,8 @@ void* autocalibrate_hello(void *NULL_value) sleep(GET_AUTOCALIBRATION_HELLO_DELAY()) ; } - close(send_sockfd) ; + /* Close the socket */ + pthread_cleanup_pop(1) ; pthread_exit(NULL_value) ; } @@ -1087,6 +1089,7 @@ void* autocalibrate(void *NULL_value) " aggregation server") ; exit(ERR_CREATING_SOCKET) ; } + pthread_cleanup_push(&owl_close_fd, &listen_sockfd) ; while (run) { @@ -1112,7 +1115,8 @@ void* autocalibrate(void *NULL_value) "Autocalibration order unknown: %d.\n", message.order) ; } - close(listen_sockfd) ; + /* Close the socket */ + pthread_cleanup_pop(1) ; pthread_exit(NULL_value) ; }