diff options
author | Peter Wemm <peter@FreeBSD.org> | 2015-08-09 04:37:39 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2015-08-09 04:37:39 +0000 |
commit | 58218291fa73a17020ef0447398e9e8a78f9e8c7 (patch) | |
tree | 78a13bd0acf7405df6eb6ca94a4e354d124065a6 /subversion/libsvn_subr/dso.c | |
parent | 6f0665939667af9f780762878fc35982e8b7d745 (diff) |
Notes
Diffstat (limited to 'subversion/libsvn_subr/dso.c')
-rw-r--r-- | subversion/libsvn_subr/dso.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/subversion/libsvn_subr/dso.c b/subversion/libsvn_subr/dso.c index 3fa251798953..7cce2fd34560 100644 --- a/subversion/libsvn_subr/dso.c +++ b/subversion/libsvn_subr/dso.c @@ -28,6 +28,7 @@ #include "svn_private_config.h" #include "private/svn_mutex.h" +#include "private/svn_atomic.h" /* A mutex to protect our global pool and cache. */ static svn_mutex__t *dso_mutex = NULL; @@ -41,18 +42,18 @@ static apr_hash_t *dso_cache; /* Just an arbitrary location in memory... */ static int not_there_sentinel; +static volatile svn_atomic_t atomic_init_status = 0; + /* A specific value we store in the dso_cache to indicate that the library wasn't found. This keeps us from allocating extra memory from dso_pool when trying to find libraries we already know aren't there. */ #define NOT_THERE ((void *) ¬_there_sentinel) -svn_error_t * -svn_dso_initialize2(void) +static svn_error_t * +atomic_init_func(void *baton, + apr_pool_t *pool) { - if (dso_pool) - return SVN_NO_ERROR; - dso_pool = svn_pool_create(NULL); SVN_ERR(svn_mutex__init(&dso_mutex, TRUE, dso_pool)); @@ -61,6 +62,15 @@ svn_dso_initialize2(void) return SVN_NO_ERROR; } +svn_error_t * +svn_dso_initialize2(void) +{ + SVN_ERR(svn_atomic__init_once(&atomic_init_status, atomic_init_func, + NULL, NULL)); + + return SVN_NO_ERROR; +} + #if APR_HAS_DSO static svn_error_t * svn_dso_load_internal(apr_dso_handle_t **dso, const char *fname) @@ -107,8 +117,7 @@ svn_dso_load_internal(apr_dso_handle_t **dso, const char *fname) svn_error_t * svn_dso_load(apr_dso_handle_t **dso, const char *fname) { - if (! dso_pool) - SVN_ERR(svn_dso_initialize2()); + SVN_ERR(svn_dso_initialize2()); SVN_MUTEX__WITH_LOCK(dso_mutex, svn_dso_load_internal(dso, fname)); |