[Listener] Use pthread_cleanup*

This commit is contained in:
Matteo Cypriani 2011-03-24 10:38:01 +01:00
parent a3f0fb4130
commit 0a52205916
1 changed files with 6 additions and 2 deletions

View File

@ -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) ;
}