Fixing thread cancellation.
This commit is contained in:
parent
e82514a56a
commit
5a53d3681d
@ -118,6 +118,10 @@ int NeoComm_bind(const unsigned short port) {
|
||||
}
|
||||
|
||||
void *NeoComm_connect_manager() {
|
||||
// Allow for thread to be cancelled asynchronously
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||
|
||||
while(run)
|
||||
{
|
||||
int cli_sockfd;
|
||||
@ -181,15 +185,13 @@ void NeoComm_shutdown_directory() {
|
||||
if(!node_list)
|
||||
return;
|
||||
run = 0;
|
||||
void *res;
|
||||
pthread_cancel(accept_thread);
|
||||
for(unsigned int i = 0; i < num_nodes; ++i)
|
||||
{
|
||||
// in case the threads are still running, we wait
|
||||
pthread_join(node_list[i].thread, &res);
|
||||
pthread_cancel(node_list[i].thread);
|
||||
close(node_list[i].sockfd);
|
||||
}
|
||||
num_nodes = 0;
|
||||
pthread_join(accept_thread, &res);
|
||||
close(sockfd);
|
||||
|
||||
free(node_list);
|
||||
|
Loading…
Reference in New Issue
Block a user