Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
112e19a5
Unverified
Commit
112e19a5
authored
May 14, 2020
by
Salvatore Sanfilippo
Committed by
GitHub
May 14, 2020
Browse files
Merge pull request #7230 from yossigo/tls-crypto-locks
TLS: Add crypto locks for older OpenSSL support.
parents
67a4fb91
450f0d72
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/tls.c
View file @
112e19a5
...
...
@@ -93,11 +93,56 @@ static int parseProtocolsConfig(const char *str) {
* served to the reader yet. */
static
list
*
pending_list
=
NULL
;
/**
* OpenSSL global initialization and locking handling callbacks.
* Note that this is only required for OpenSSL < 1.1.0.
*/
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define USE_CRYPTO_LOCKS
#endif
#ifdef USE_CRYPTO_LOCKS
static
pthread_mutex_t
*
openssl_locks
;
static
void
sslLockingCallback
(
int
mode
,
int
lock_id
,
const
char
*
f
,
int
line
)
{
pthread_mutex_t
*
mt
=
openssl_locks
+
lock_id
;
if
(
mode
&
CRYPTO_LOCK
)
{
pthread_mutex_lock
(
mt
);
}
else
{
pthread_mutex_unlock
(
mt
);
}
(
void
)
f
;
(
void
)
line
;
}
static
void
initCryptoLocks
(
void
)
{
unsigned
i
,
nlocks
;
if
(
CRYPTO_get_locking_callback
()
!=
NULL
)
{
/* Someone already set the callback before us. Don't destroy it! */
return
;
}
nlocks
=
CRYPTO_num_locks
();
openssl_locks
=
zmalloc
(
sizeof
(
*
openssl_locks
)
*
nlocks
);
for
(
i
=
0
;
i
<
nlocks
;
i
++
)
{
pthread_mutex_init
(
openssl_locks
+
i
,
NULL
);
}
CRYPTO_set_locking_callback
(
sslLockingCallback
);
}
#endif
/* USE_CRYPTO_LOCKS */
void
tlsInit
(
void
)
{
ERR_load_crypto_strings
();
SSL_load_error_strings
();
SSL_library_init
();
#ifdef USE_CRYPTO_LOCKS
initCryptoLocks
();
#endif
if
(
!
RAND_poll
())
{
serverLog
(
LL_WARNING
,
"OpenSSL: Failed to seed random number generator."
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment