Ejemplo n.º 1
0
static void
ossl_lock_unlock(int mode, rb_nativethread_lock_t *lock)
{
    if (mode & CRYPTO_LOCK) {
	rb_nativethread_lock_lock(lock);
    } else {
	rb_nativethread_lock_unlock(lock);
    }
}
Ejemplo n.º 2
0
static void
ossl_lock_unlock(int mode, struct CRYPTO_dynlock_value *l)
{
    if (mode & CRYPTO_LOCK) {
	/* TODO: rb_nativethread_id_t is not necessarily compared with ==. */
	rb_nativethread_id_t tid = rb_nativethread_self();
	if (l->count && l->owner == tid) {
	    l->count++;
	    return;
	}
	rb_nativethread_lock_lock(&l->lock);
	l->owner = tid;
	l->count = 1;
    } else {
	if (!--l->count)
	    rb_nativethread_lock_unlock(&l->lock);
    }
}