reverting RCU changes back (#47)
Co-authored-by: neelimap <neelimaps@neominds.in> Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/47 Co-authored-by: Neelima P S <neelima.ps@neominds.in> Co-committed-by: Neelima P S <neelima.ps@neominds.in>
This commit is contained in:
committed by
neelimap
co-authored by
neelimap
parent
84c6fbc79b
commit
baa4eb0263
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef RCU_VX69_H
|
||||||
|
#define RCU_VX69_H
|
||||||
|
|
||||||
#include <semLib.h>
|
#include <semLib.h>
|
||||||
#include <vxAtomicLib.h>
|
#include <vxAtomicLib.h>
|
||||||
#include "../crypto/rcu_internal.h"
|
#include "../crypto/rcu_internal.h"
|
||||||
@@ -6,8 +9,6 @@ typedef struct crypto_rwlock_st {
|
|||||||
SEM_ID sem;
|
SEM_ID sem;
|
||||||
}CRYPTO_RWLOCK_VX;
|
}CRYPTO_RWLOCK_VX;
|
||||||
|
|
||||||
static CRYPTO_RWLOCK_VX *local_rcu_rwlock;
|
|
||||||
static int is_rwlock_init = 0;
|
|
||||||
|
|
||||||
/*---------- Atomic routines ----------*/
|
/*---------- Atomic routines ----------*/
|
||||||
int CRYPTO_atomic_load_int(int *val, int *ret, CRYPTO_RWLOCK *lock)
|
int CRYPTO_atomic_load_int(int *val, int *ret, CRYPTO_RWLOCK *lock)
|
||||||
@@ -47,30 +48,14 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
|
|||||||
if (!lock)
|
if (!lock)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
lock->writer_lock = semBCreate (SEM_Q_PRIORITY |
|
lock->writer_lock = semBCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE, SEM_EMPTY);
|
||||||
SEM_DELETE_SAFE | SEM_INVERSION_SAFE,
|
|
||||||
SEM_EMPTY);
|
|
||||||
lock->active_readers = 0;
|
lock->active_readers = 0;
|
||||||
|
|
||||||
if (!is_rwlock_init)
|
|
||||||
{
|
|
||||||
local_rcu_rwlock->sem = semBCreate (SEM_Q_PRIORITY |
|
|
||||||
SEM_DELETE_SAFE | SEM_INVERSION_SAFE,
|
|
||||||
SEM_EMPTY);
|
|
||||||
is_rwlock_init = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lock;
|
return lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
|
void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
|
||||||
{
|
{
|
||||||
if (is_rwlock_init)
|
|
||||||
{
|
|
||||||
semDelete (local_rcu_rwlock->sem);
|
|
||||||
is_rwlock_init = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lock) return;
|
if (!lock) return;
|
||||||
|
|
||||||
semDelete (lock->writer_lock);
|
semDelete (lock->writer_lock);
|
||||||
@@ -105,17 +90,13 @@ void *ossl_rcu_uptr_deref(void **p)
|
|||||||
|
|
||||||
void ossl_rcu_assign_uptr(void **p, void **v)
|
void ossl_rcu_assign_uptr(void **p, void **v)
|
||||||
{
|
{
|
||||||
void *ret, *val;
|
|
||||||
ret = p;
|
|
||||||
val = v;
|
|
||||||
|
|
||||||
/* publish new pointer immediately */
|
/* publish new pointer immediately */
|
||||||
CRYPTO_atomic_load_int (val, ret, local_rcu_rwlock);
|
*p = *v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
|
void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
|
||||||
{
|
{
|
||||||
int retVal=0;
|
|
||||||
struct rcu_cb_item *cb_items, *tmpcb;
|
struct rcu_cb_item *cb_items, *tmpcb;
|
||||||
|
|
||||||
semBTake (lock->writer_lock, WAIT_FOREVER);
|
semBTake (lock->writer_lock, WAIT_FOREVER);
|
||||||
@@ -124,10 +105,8 @@ void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
|
|||||||
semBGive (lock->writer_lock);
|
semBGive (lock->writer_lock);
|
||||||
|
|
||||||
/* Wait until all readers finish */
|
/* Wait until all readers finish */
|
||||||
do {
|
while (lock->active_readers > 0)
|
||||||
CRYPTO_atomic_load_int(&(lock->active_readers), &retVal, local_rcu_rwlock);
|
taskDelay(1);
|
||||||
taskDelay(0);
|
|
||||||
}while (retVal > 0);
|
|
||||||
|
|
||||||
/* handle any callbacks that we have */
|
/* handle any callbacks that we have */
|
||||||
while (cb_items != NULL) {
|
while (cb_items != NULL) {
|
||||||
@@ -156,3 +135,4 @@ int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user