From a3c77cfdd7d80ecd5f341913902410c5827f8840 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Mon, 30 Oct 2017 23:44:40 +0100 Subject: [PATCH] MINOR: shctx: rename lock functions Rename lock functions to shctx_lock() and shctx_unlock() to be coherent with the new API. --- include/proto/shctx.h | 28 ++++++++++++++-------------- src/ssl_sock.c | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/proto/shctx.h b/include/proto/shctx.h index 2e72451d3..55cb2a772 100644 --- a/include/proto/shctx.h +++ b/include/proto/shctx.h @@ -45,25 +45,25 @@ int shctx_row_data_get(struct shared_context *shctx, struct shared_block *first, #if defined (USE_PRIVATE_CACHE) -#define shared_context_lock(shctx) -#define shared_context_unlock(shctx) +#define shctx_lock(shctx) +#define shctx_unlock(shctx) #elif defined (USE_PTHREAD_PSHARED) extern int use_shared_mem; -#define shared_context_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_lock(shctx) if (use_shared_mem) pthread_mutex_lock(&shctx->mutex) +#define shctx_unlock(shctx) if (use_shared_mem) pthread_mutex_unlock(&shctx->mutex) #else extern int use_shared_mem; #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); } -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); } @@ -82,7 +82,7 @@ static inline void relax() } #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; @@ -93,7 +93,7 @@ static inline void _shared_context_wait4lock(unsigned int *count, unsigned int * *count = *count << 1; } -#define _shared_context_awakelocker(a) +#define _shctx_awakelocker(a) #endif @@ -147,7 +147,7 @@ static inline unsigned char atomic_dec(unsigned int *ptr) #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 count = 4; @@ -158,23 +158,23 @@ static inline void _shared_context_lock(struct shared_context *shctx) x = xchg(&shctx->waiters, 2); while (x) { - _shared_context_wait4lock(&count, &shctx->waiters, 2); + _shctx_wait4lock(&count, &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)) { 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 diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 09e27b30c..13d952652 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -3821,10 +3821,10 @@ int sh_ssl_sess_new_cb(SSL *ssl, SSL_SESSION *sess) if (sid_length < SSL_MAX_SSL_SESSION_ID_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 */ sh_ssl_sess_store(encid, encsess, data_len); - shared_context_unlock(ssl_shctx); + shctx_unlock(ssl_shctx); err: /* reset original length values */ 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 */ - shared_context_lock(ssl_shctx); + shctx_lock(ssl_shctx); /* lookup for session */ sh_ssl_sess = sh_ssl_sess_tree_lookup(key); if (!sh_ssl_sess) { /* no session found: unlock cache and exit */ - shared_context_unlock(ssl_shctx); + shctx_unlock(ssl_shctx); global.shctx_misses++; 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)); - shared_context_unlock(ssl_shctx); + shctx_unlock(ssl_shctx); /* decode ASN1 session */ p = data; @@ -3903,7 +3903,7 @@ void sh_ssl_sess_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess) sid_data = tmpkey; } - shared_context_lock(ssl_shctx); + shctx_lock(ssl_shctx); /* lookup for session */ 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 */ - shared_context_unlock(ssl_shctx); + shctx_unlock(ssl_shctx); } /* Set session cache mode to server and disable openssl internal cache.