MINOR: shctx: rename lock functions

Rename lock functions to shctx_lock() and shctx_unlock() to be coherent
with the new API.
This commit is contained in:
William Lallemand 2017-10-30 23:44:40 +01:00 committed by Willy Tarreau
parent 4f45bb9c46
commit a3c77cfdd7
2 changed files with 21 additions and 21 deletions

View File

@ -45,25 +45,25 @@ int shctx_row_data_get(struct shared_context *shctx, struct shared_block *first,
#if defined (USE_PRIVATE_CACHE) #if defined (USE_PRIVATE_CACHE)
#define shared_context_lock(shctx) #define shctx_lock(shctx)
#define shared_context_unlock(shctx) #define shctx_unlock(shctx)
#elif defined (USE_PTHREAD_PSHARED) #elif defined (USE_PTHREAD_PSHARED)
extern int use_shared_mem; extern int use_shared_mem;
#define shared_context_lock(shctx) if (use_shared_mem) pthread_mutex_lock(&shctx->mutex) #define shctx_lock(shctx) if (use_shared_mem) pthread_mutex_lock(&shctx->mutex)
#define shared_context_unlock(shctx) if (use_shared_mem) pthread_mutex_unlock(&shctx->mutex) #define shctx_unlock(shctx) if (use_shared_mem) pthread_mutex_unlock(&shctx->mutex)
#else #else
extern int use_shared_mem; extern int use_shared_mem;
#ifdef USE_SYSCALL_FUTEX #ifdef USE_SYSCALL_FUTEX
static inline void _shared_context_wait4lock(unsigned int *count, unsigned int *uaddr, int value) static inline void _shctx_wait4lock(unsigned int *count, unsigned int *uaddr, int value)
{ {
syscall(SYS_futex, uaddr, FUTEX_WAIT, value, NULL, 0, 0); syscall(SYS_futex, uaddr, FUTEX_WAIT, value, NULL, 0, 0);
} }
static inline void _shared_context_awakelocker(unsigned int *uaddr) static inline void _shctx_awakelocker(unsigned int *uaddr)
{ {
syscall(SYS_futex, uaddr, FUTEX_WAKE, 1, NULL, 0, 0); syscall(SYS_futex, uaddr, FUTEX_WAKE, 1, NULL, 0, 0);
} }
@ -82,7 +82,7 @@ static inline void relax()
} }
#endif #endif
static inline void _shared_context_wait4lock(unsigned int *count, unsigned int *uaddr, int value) static inline void _shctx_wait4lock(unsigned int *count, unsigned int *uaddr, int value)
{ {
int i; int i;
@ -93,7 +93,7 @@ static inline void _shared_context_wait4lock(unsigned int *count, unsigned int *
*count = *count << 1; *count = *count << 1;
} }
#define _shared_context_awakelocker(a) #define _shctx_awakelocker(a)
#endif #endif
@ -147,7 +147,7 @@ static inline unsigned char atomic_dec(unsigned int *ptr)
#endif #endif
static inline void _shared_context_lock(struct shared_context *shctx) static inline void _shctx_lock(struct shared_context *shctx)
{ {
unsigned int x; unsigned int x;
unsigned int count = 4; unsigned int count = 4;
@ -158,23 +158,23 @@ static inline void _shared_context_lock(struct shared_context *shctx)
x = xchg(&shctx->waiters, 2); x = xchg(&shctx->waiters, 2);
while (x) { while (x) {
_shared_context_wait4lock(&count, &shctx->waiters, 2); _shctx_wait4lock(&count, &shctx->waiters, 2);
x = xchg(&shctx->waiters, 2); x = xchg(&shctx->waiters, 2);
} }
} }
} }
static inline void _shared_context_unlock(struct shared_context *shctx) static inline void _shctx_unlock(struct shared_context *shctx)
{ {
if (atomic_dec(&shctx->waiters)) { if (atomic_dec(&shctx->waiters)) {
shctx->waiters = 0; shctx->waiters = 0;
_shared_context_awakelocker(&shctx->waiters); _shctx_awakelocker(&shctx->waiters);
} }
} }
#define shared_context_lock(shctx) if (use_shared_mem) _shared_context_lock(shctx) #define shctx_lock(shctx) if (use_shared_mem) _shctx_lock(shctx)
#define shared_context_unlock(shctx) if (use_shared_mem) _shared_context_unlock(shctx) #define shctx_unlock(shctx) if (use_shared_mem) _shctx_unlock(shctx)
#endif #endif

View File

@ -3821,10 +3821,10 @@ int sh_ssl_sess_new_cb(SSL *ssl, SSL_SESSION *sess)
if (sid_length < SSL_MAX_SSL_SESSION_ID_LENGTH) if (sid_length < SSL_MAX_SSL_SESSION_ID_LENGTH)
memset(encid + sid_length, 0, SSL_MAX_SSL_SESSION_ID_LENGTH-sid_length); memset(encid + sid_length, 0, SSL_MAX_SSL_SESSION_ID_LENGTH-sid_length);
shared_context_lock(ssl_shctx); shctx_lock(ssl_shctx);
/* store to cache */ /* store to cache */
sh_ssl_sess_store(encid, encsess, data_len); sh_ssl_sess_store(encid, encsess, data_len);
shared_context_unlock(ssl_shctx); shctx_unlock(ssl_shctx);
err: err:
/* reset original length values */ /* reset original length values */
SSL_SESSION_set1_id(sess, sid_data, sid_length); SSL_SESSION_set1_id(sess, sid_data, sid_length);
@ -3855,13 +3855,13 @@ SSL_SESSION *sh_ssl_sess_get_cb(SSL *ssl, __OPENSSL_110_CONST__ unsigned char *k
} }
/* lock cache */ /* lock cache */
shared_context_lock(ssl_shctx); shctx_lock(ssl_shctx);
/* lookup for session */ /* lookup for session */
sh_ssl_sess = sh_ssl_sess_tree_lookup(key); sh_ssl_sess = sh_ssl_sess_tree_lookup(key);
if (!sh_ssl_sess) { if (!sh_ssl_sess) {
/* no session found: unlock cache and exit */ /* no session found: unlock cache and exit */
shared_context_unlock(ssl_shctx); shctx_unlock(ssl_shctx);
global.shctx_misses++; global.shctx_misses++;
return NULL; return NULL;
} }
@ -3871,7 +3871,7 @@ SSL_SESSION *sh_ssl_sess_get_cb(SSL *ssl, __OPENSSL_110_CONST__ unsigned char *k
shctx_row_data_get(ssl_shctx, first, data, sizeof(struct sh_ssl_sess_hdr), first->len-sizeof(struct sh_ssl_sess_hdr)); shctx_row_data_get(ssl_shctx, first, data, sizeof(struct sh_ssl_sess_hdr), first->len-sizeof(struct sh_ssl_sess_hdr));
shared_context_unlock(ssl_shctx); shctx_unlock(ssl_shctx);
/* decode ASN1 session */ /* decode ASN1 session */
p = data; p = data;
@ -3903,7 +3903,7 @@ void sh_ssl_sess_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess)
sid_data = tmpkey; sid_data = tmpkey;
} }
shared_context_lock(ssl_shctx); shctx_lock(ssl_shctx);
/* lookup for session */ /* lookup for session */
sh_ssl_sess = sh_ssl_sess_tree_lookup(sid_data); sh_ssl_sess = sh_ssl_sess_tree_lookup(sid_data);
@ -3913,7 +3913,7 @@ void sh_ssl_sess_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess)
} }
/* unlock cache */ /* unlock cache */
shared_context_unlock(ssl_shctx); shctx_unlock(ssl_shctx);
} }
/* Set session cache mode to server and disable openssl internal cache. /* Set session cache mode to server and disable openssl internal cache.