{
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")
)
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)
{
{
#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");
#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);
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 */
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);