fix: thead leaks fixed
This commit is contained in:
parent
d0b1fa6329
commit
2040551742
@ -52,7 +52,6 @@ void *routine(void *p_data)
|
|||||||
pthread_mutex_lock(&g_nb_threads_mtx);
|
pthread_mutex_lock(&g_nb_threads_mtx);
|
||||||
g_nb_threads--;
|
g_nb_threads--;
|
||||||
pthread_mutex_unlock(&g_nb_threads_mtx);
|
pthread_mutex_unlock(&g_nb_threads_mtx);
|
||||||
free(p_data);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -105,6 +104,7 @@ int create_threads(const struct option_lst *options, char *ip_addr,
|
|||||||
thread_data->port_end = port_end;
|
thread_data->port_end = port_end;
|
||||||
g_start = true;
|
g_start = true;
|
||||||
routine(thread_data);
|
routine(thread_data);
|
||||||
|
free(thread_data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +139,7 @@ int create_threads(const struct option_lst *options, char *ip_addr,
|
|||||||
dprintf(2, "ft_nmap: error during pthread_create()\n");
|
dprintf(2, "ft_nmap: error during pthread_create()\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
pthread_detach(threads[i]);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&g_start_mtx);
|
pthread_mutex_lock(&g_start_mtx);
|
||||||
g_start = true;
|
g_start = true;
|
||||||
@ -152,6 +153,8 @@ int create_threads(const struct option_lst *options, char *ip_addr,
|
|||||||
break;
|
break;
|
||||||
usleep(100);
|
usleep(100);
|
||||||
}
|
}
|
||||||
|
free(threads_data);
|
||||||
|
free(threads);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user