summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/openssl.c b/src/openssl.c
index df559d7..9fc5b97 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -1227,17 +1227,14 @@ static const EVP_MD *auxL_optdigest(lua_State *L, int index, EVP_PKEY *key, cons
1227 * Prevent loader from unlinking us if we've registered a callback with 1227 * Prevent loader from unlinking us if we've registered a callback with
1228 * OpenSSL by taking another reference to ourselves. 1228 * OpenSSL by taking another reference to ourselves.
1229 */ 1229 */
1230/* dl_anchor must not be called from multiple threads at once */
1230static int dl_anchor(void) { 1231static int dl_anchor(void) {
1231#if HAVE_DLADDR 1232#if HAVE_DLADDR
1232 extern int luaopen__openssl(lua_State *); 1233 extern int luaopen__openssl(lua_State *);
1233 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
1234 static void *anchor; 1234 static void *anchor;
1235 Dl_info info; 1235 Dl_info info;
1236 int error = 0; 1236 int error = 0;
1237 1237
1238 if ((error = pthread_mutex_lock(&mutex)))
1239 return error;
1240
1241 if (anchor) 1238 if (anchor)
1242 goto epilog; 1239 goto epilog;
1243 1240
@@ -1247,8 +1244,6 @@ static int dl_anchor(void) {
1247 if (!(anchor = dlopen(info.dli_fname, RTLD_NOW|RTLD_LOCAL))) 1244 if (!(anchor = dlopen(info.dli_fname, RTLD_NOW|RTLD_LOCAL)))
1248 goto dlerr; 1245 goto dlerr;
1249epilog: 1246epilog:
1250 (void)pthread_mutex_unlock(&mutex);
1251
1252 return error; 1247 return error;
1253dlerr: 1248dlerr:
1254 error = auxL_EDYLD; 1249 error = auxL_EDYLD;