Join pluto's fetching thread instead of detaching it in order to avoid that the leak-detective reports a memleak.
This commit is contained in:
parent
b7fd2ea76c
commit
dc5969242f
|
@ -450,6 +450,9 @@ static void* fetch_thread(void *arg)
|
|||
{
|
||||
struct timespec wait_interval;
|
||||
|
||||
/* the fetching thread is only cancellable while waiting for new events */
|
||||
thread_cancelability(FALSE);
|
||||
|
||||
DBG(DBG_CONTROL,
|
||||
DBG_log("fetch thread started")
|
||||
)
|
||||
|
@ -466,8 +469,11 @@ static void* fetch_thread(void *arg)
|
|||
DBG(DBG_CONTROL,
|
||||
DBG_log("next regular crl check in %ld seconds", crl_check_interval)
|
||||
)
|
||||
|
||||
thread_cancelability(TRUE);
|
||||
status = pthread_cond_timedwait(&fetch_wake_cond, &fetch_wake_mutex
|
||||
, &wait_interval);
|
||||
thread_cancelability(FALSE);
|
||||
|
||||
if (status == ETIMEDOUT)
|
||||
{
|
||||
|
@ -500,21 +506,33 @@ void init_fetch(void)
|
|||
{
|
||||
#ifdef THREADS
|
||||
thread = thread_create((thread_main_t)fetch_thread, NULL);
|
||||
|
||||
if (thread == NULL)
|
||||
{
|
||||
plog("fetching thread could not be started");
|
||||
}
|
||||
else
|
||||
{
|
||||
thread->detach(thread);
|
||||
}
|
||||
#else /* !THREADS */
|
||||
plog("warning: not compiled with pthread support");
|
||||
#endif /* !THREADS */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminates the fetching thread
|
||||
*/
|
||||
void fetch_finalize(void)
|
||||
{
|
||||
if (crl_check_interval > 0)
|
||||
{
|
||||
#ifdef THREADS
|
||||
if (thread)
|
||||
{
|
||||
thread->cancel(thread);
|
||||
thread->join(thread);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void free_crl_fetch(void)
|
||||
{
|
||||
lock_crl_fetch_list("free_crl_fetch");
|
||||
|
|
|
@ -63,6 +63,7 @@ extern void wake_fetch_thread(const char *who);
|
|||
#define wake_fetch_thread(who) /* do nothing */
|
||||
#endif
|
||||
extern void init_fetch(void);
|
||||
extern void fetch_finalize(void);
|
||||
extern void free_crl_fetch(void);
|
||||
extern void free_ocsp_fetch(void);
|
||||
extern void add_distribution_point(linked_list_t *points, char* new_point);
|
||||
|
|
|
@ -750,6 +750,7 @@ void exit_pluto(int status)
|
|||
free_preshared_secrets();
|
||||
free_remembered_public_keys();
|
||||
delete_every_connection();
|
||||
fetch_finalize(); /* stop fetching thread */
|
||||
free_crl_fetch(); /* free chain of crl fetch requests */
|
||||
free_ocsp_fetch(); /* free chain of ocsp fetch requests */
|
||||
free_authcerts(); /* free chain of X.509 authority certificates */
|
||||
|
@ -765,7 +766,7 @@ void exit_pluto(int status)
|
|||
free_crypto();
|
||||
free_myid(); /* free myids */
|
||||
free_events(); /* free remaining events */
|
||||
free_vendorid(); /* free all vendor id records */
|
||||
free_vendorid(); /* free all vendor id records */
|
||||
free_builder();
|
||||
delete_lock();
|
||||
options->destroy(options);
|
||||
|
|
Loading…
Reference in New Issue