--- srclib/apr/dso/unix/dso.c.origSat Feb 5 05:44:01 2005
+++ srclib/apr/dso/unix/dso.cFri Mar 17 23:10:30 2006
@@ -38,6 +38,10 @@
#define DYLD_LIBRARY_HANDLE (void *)-1
#endif

+#if defined(__FreeBSD__)
+static pthread_mutex_t dlmutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
apr_os_dso_handle_t osdso,
apr_pool_t *pool)
@@ -62,6 +66,9 @@
if (dso->handle == NULL)
return APR_SUCCESS;

+#if defined(__FreeBSD__)
+ pthread_mutex_lock(&dlmutex);
+#endif
#if defined(DSO_USE_SHL)
shl_unload((shl_t)dso->handle);
#elif defined(DSO_USE_DYLD)
@@ -69,8 +76,15 @@
NSUnLinkModule(dso->handle, FALSE);
}
#elif defined(DSO_USE_DLFCN)
- if (dlclose(dso->handle) != 0)
+ if (dlclose(dso->handle) != 0) {
+#if defined(__FreeBSD__)
+ pthread_mutex_unlock(&dlmutex);
+#endif
return APR_EINIT;
+ }
+#endif
+#if defined(__FreeBSD__)
+ pthread_mutex_unlock(&dlmutex);
#endif
dso->handle = NULL;

@@ -80,6 +94,9 @@
APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle,
const char *path, apr_pool_t *pool)
{
+#if defined(__FreeBSD__)
+ pthread_mutex_lock(&dlmutex);
+#endif
#if defined(DSO_USE_SHL)
shl_t os_handle = shl_load(path, BIND_IMMEDIATE, 0L);

@@ -139,6 +156,9 @@
os_handle = dlopen(path, flags);
#endif
#endif /* DSO_USE_x */
+#if defined(__FreeBSD__)
+ pthread_mutex_unlock(&dlmutex);
+#endif

*res_handle = apr_pcalloc(pool, sizeof(**res_handle));