#include <daemon.h>
#include <threading/thread_value.h>
+#include <threading/mutex.h>
#include <threading/rwlock.h>
#include <utils/linked_list.h>
#include <credentials/sets/cert_cache.h>
* read-write lock to sets list
*/
rwlock_t *lock;
+
+ /**
+ * mutex for cache queue
+ */
+ mutex_t *queue_mutex;
};
/** data to pass to create_private_enumerator */
set->cache_cert(set, cert);
}
enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
}
else
{ /* we can't cache now as other threads are active, queue for later */
- this->lock->read_lock(this->lock);
+ this->queue_mutex->lock(this->queue_mutex);
this->cache_queue->insert_last(this->cache_queue, cert->get_ref(cert));
+ this->queue_mutex->unlock(this->queue_mutex);
}
- this->lock->unlock(this->lock);
}
/**
certificate_t *cert;
enumerator_t *enumerator;
+ this->queue_mutex->lock(this->queue_mutex);
if (this->cache_queue->get_count(this->cache_queue) > 0 &&
this->lock->try_write_lock(this->lock))
{
}
this->lock->unlock(this->lock);
}
+ this->queue_mutex->unlock(this->queue_mutex);
}
/**
this->local_sets->destroy(this->local_sets);
this->cache->destroy(this->cache);
this->lock->destroy(this->lock);
+ this->queue_mutex->destroy(this->queue_mutex);
free(this);
}
this->cache_queue = linked_list_create();
this->sets->insert_first(this->sets, this->cache);
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
+ this->queue_mutex = mutex_create(MUTEX_TYPE_DEFAULT);
return &this->public;
}