apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r659294 - in /apr/apr-util/branches/1.3.x: ./ build/ dbd/ include/ include/private/ ldap/ misc/ test/
Date Thu, 22 May 2008 22:37:49 GMT
Author: wrowe
Date: Thu May 22 15:37:47 2008
New Revision: 659294

URL: http://svn.apache.org/viewvc?rev=659294&view=rev
Log:
Introduce an internal apu_dso API for loading modular components into the
core library, even across multiple consumers.  Rearranges apr_dbd into this
schema to ensure consumers do not corrupt one another, and to respect the
platform specific shared lib search path - especially for pre-installation
`make check`.  Abstracts ldap into the apu_dso schema, with a note in CHANGES 
for changes required by apps which consume the ldap library directly.

Backports: r659293

Added:
    apr/apr-util/branches/1.3.x/include/private/apu_internal.h   (with props)
    apr/apr-util/branches/1.3.x/ldap/apr_ldap_stub.c   (with props)
    apr/apr-util/branches/1.3.x/misc/apu_dso.c   (with props)
Modified:
    apr/apr-util/branches/1.3.x/CHANGES
    apr/apr-util/branches/1.3.x/Makefile.in
    apr/apr-util/branches/1.3.x/apu-config.in
    apr/apr-util/branches/1.3.x/build.conf
    apr/apr-util/branches/1.3.x/build/apu-conf.m4
    apr/apr-util/branches/1.3.x/build/dbd.m4
    apr/apr-util/branches/1.3.x/configure.in
    apr/apr-util/branches/1.3.x/dbd/apr_dbd.c
    apr/apr-util/branches/1.3.x/include/apr_ldap.h.in
    apr/apr-util/branches/1.3.x/include/apr_ldap.hnw
    apr/apr-util/branches/1.3.x/include/apr_ldap.hw
    apr/apr-util/branches/1.3.x/ldap/apr_ldap_init.c
    apr/apr-util/branches/1.3.x/test/Makefile.in

Modified: apr/apr-util/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/CHANGES?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.3.x/CHANGES [utf-8] Thu May 22 15:37:47 2008
@@ -1,6 +1,12 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR-util 1.3.0
 
+  *) Modularize ldap's stub with the dbd dso modular structure, and teach
+     the apu dso's to respect the system specific shared lib path var.
+     To link to the native ldap libs, query `apu-1-config --ldap-libs`
+     (in addition to the usual linker queries for compiling and linking).
+     [William Rowe]
+
   *) All DBD drivers now count rows from 1, which affects PostgreSQL and MySQL
      drivers in particular. Using row number zero is an error.
      [Bojan Smojver]

Modified: apr/apr-util/branches/1.3.x/Makefile.in
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/Makefile.in?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/Makefile.in (original)
+++ apr/apr-util/branches/1.3.x/Makefile.in Thu May 22 15:37:47 2008
@@ -35,6 +35,7 @@
 LDADD_dbd_sqlite2 = @LDADD_dbd_sqlite2@
 LDADD_dbd_sqlite3 = @LDADD_dbd_sqlite3@
 LDADD_dbd_mysql = @LDADD_dbd_mysql@
+LDADD_ldap = @LDADD_ldap@
 
 TARGETS = $(TARGET_LIB) aprutil.exp apu-config.out $(APU_MODULES)
 

Modified: apr/apr-util/branches/1.3.x/apu-config.in
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/apu-config.in?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/apu-config.in (original)
+++ apr/apr-util/branches/1.3.x/apu-config.in Thu May 22 15:37:47 2008
@@ -30,6 +30,7 @@
 LIBS="@APRUTIL_EXPORT_LIBS@"
 INCLUDES="@APRUTIL_INCLUDES@"
 LDFLAGS="@APRUTIL_LDFLAGS@"
+LDAP_LIBS="@LDADD_ldap@"
 
 APRUTIL_LIBNAME="@APRUTIL_LIBNAME@"
 
@@ -53,6 +54,7 @@
   --includedir      print location where headers are installed
   --ldflags         print linker flags
   --libs            print library information
+  --ldap-libs       print additional library information to link with ldap
   --srcdir          print APR-util source directory
   --link-ld         print link switch(es) for linking to APR-util
   --link-libtool    print the libtool inputs for linking to APR-util
@@ -112,6 +114,9 @@
     --libs)
     flags="$flags $LIBS"
     ;;
+    --ldap-libs)
+    flags="$flags $LDAP_LIBS"
+    ;;
     --includedir)
     if test "$location" = "installed"; then
         flags="$includedir"

Modified: apr/apr-util/branches/1.3.x/build.conf
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/build.conf?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/build.conf (original)
+++ apr/apr-util/branches/1.3.x/build.conf Thu May 22 15:37:47 2008
@@ -12,7 +12,8 @@
   dbm/sdbm/*.c
   encoding/*.c
   hooks/*.c
-  ldap/*.c
+  ldap/apr_ldap_stub.c
+  ldap/apr_ldap_url.c
   misc/*.c
   memcache/*.c
   uri/apr_uri.c
@@ -28,7 +29,7 @@
 # the public headers
 headers = include/*.h include/private/*.h
 
-modules = dbd_pgsql dbd_sqlite2 dbd_sqlite3 dbd_oracle dbd_mysql dbd_freetds
+modules = ldap dbd_pgsql dbd_sqlite2 dbd_sqlite3 dbd_oracle dbd_mysql dbd_freetds
 
 # gen_uri_delim.c
 
@@ -59,3 +60,8 @@
 paths = dbd/apr_dbd_freetds.c
 target = dbd/apr_dbd_freetds.la
 
+[ldap]
+paths = ldap/apr_ldap_init.c \
+        ldap/apr_ldap_option.c \
+        ldap/apr_ldap_rebind.c
+target = ldap/apr_ldap.la

Modified: apr/apr-util/branches/1.3.x/build/apu-conf.m4
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/build/apu-conf.m4?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/build/apu-conf.m4 (original)
+++ apr/apr-util/branches/1.3.x/build/apu-conf.m4 Thu May 22 15:37:47 2008
@@ -191,8 +191,7 @@
     unset ac_cv_lib_${ldaplib}___ldap_init
     AC_CHECK_LIB(${ldaplib}, ldap_init, 
       [
-        APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l${ldaplib} ${extralib}])
-        APR_ADDTO(APRUTIL_LIBS,[-l${ldaplib} ${extralib}])
+        LDADD_ldap="-l${ldaplib} ${extralib}"
         AC_CHECK_LIB(${ldaplib}, ldapssl_client_init, apu_has_ldapssl_client_init="1", ,
${extralib})
         AC_CHECK_LIB(${ldaplib}, ldapssl_client_deinit, apu_has_ldapssl_client_deinit="1",
, ${extralib})
         AC_CHECK_LIB(${ldaplib}, ldapssl_add_trusted_cert, apu_has_ldapssl_add_trusted_cert="1",
, ${extralib})
@@ -230,6 +229,7 @@
 apu_has_ldap_tivoli="0"
 apu_has_ldap_zos="0"
 apu_has_ldap_other="0"
+LDADD_ldap=""
 
 AC_ARG_WITH(ldap-include,[  --with-ldap-include=path  path to ldap include files with trailing
slash])
 AC_ARG_WITH(ldap-lib,[  --with-ldap-lib=path    path to ldap lib file])
@@ -376,6 +376,7 @@
 AC_SUBST(apu_has_ldap_tivoli)
 AC_SUBST(apu_has_ldap_zos)
 AC_SUBST(apu_has_ldap_other)
+AC_SUBST(LDADD_ldap)
 
 ])
 

Modified: apr/apr-util/branches/1.3.x/build/dbd.m4
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/build/dbd.m4?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/build/dbd.m4 (original)
+++ apr/apr-util/branches/1.3.x/build/dbd.m4 Thu May 22 15:37:47 2008
@@ -402,6 +402,9 @@
      test $apu_have_sqlite2 = 1 && objs="$objs dbd/apr_dbd_sqlite2.lo"
      test $apu_have_sqlite3 = 1 && objs="$objs dbd/apr_dbd_sqlite3.lo"
      test $apu_have_freetds = 1 && objs="$objs dbd/apr_dbd_freetds.lo"
+     test $apu_has_ldap = 1 && objs="$objs ldap/apr_ldap_init.lo"
+     test $apu_has_ldap = 1 && objs="$objs ldap/apr_ldap_option.lo"
+     test $apu_has_ldap = 1 && objs="$objs ldap/apr_ldap_rebind.lo"
      EXTRA_OBJECTS="$EXTRA_OBJECTS $objs"
 
      # Use libtool *.la for mysql if available
@@ -418,8 +421,8 @@
        done
      fi
 
-     APRUTIL_LIBS="$APRUTIL_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3 $LDADD_dbd_oracle
$LDADD_dbd_mysql $LDADD_dbd_freetds"
-     APRUTIL_EXPORT_LIBS="$APRUTIL_EXPORT_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3
$LDADD_dbd_oracle $LDADD_dbd_mysql $LDADD_dbd_freetds"
+     APRUTIL_LIBS="$APRUTIL_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3 $LDADD_dbd_oracle
$LDADD_dbd_mysql $LDADD_dbd_freetds $LDADD_ldap"
+     APRUTIL_EXPORT_LIBS="$APRUTIL_EXPORT_LIBS $LDADD_dbd_pgsql $LDADD_dbd_sqlite2 $LDADD_dbd_sqlite3
$LDADD_dbd_oracle $LDADD_dbd_mysql $LDADD_dbd_freetds $LDADD_ldap"
   else
      AC_DEFINE([APU_DSO_BUILD], 1, [Define if DBD drivers are built as DSOs])
      
@@ -430,6 +433,7 @@
      test $apu_have_sqlite2 = 1 && dsos="$dsos dbd/apr_dbd_sqlite2.la"
      test $apu_have_sqlite3 = 1 && dsos="$dsos dbd/apr_dbd_sqlite3.la"
      test $apu_have_freetds = 1 && dsos="$dsos dbd/apr_dbd_freetds.la"
+     test $apu_has_ldap = 1 && dsos="$dsos ldap/apr_ldap.la"
 
      APU_MODULES="$APU_MODULES $dsos"
   fi

Modified: apr/apr-util/branches/1.3.x/configure.in
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/configure.in?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/configure.in (original)
+++ apr/apr-util/branches/1.3.x/configure.in Thu May 22 15:37:47 2008
@@ -109,6 +109,8 @@
 APR_SETIFNULL(CPP, `$apr_config --cpp`)
 APR_ADDTO(CFLAGS, `$apr_config --cflags`)
 APR_ADDTO(CPPFLAGS, `$apr_config --cppflags`)
+apr_shlibpath_var=`$apr_config --shlib-path-var`
+AC_SUBST(apr_shlibpath_var)
 
 dnl
 dnl  Find the APR-ICONV directory.
@@ -154,11 +156,12 @@
 APU_CHECK_DBD_SQLITE2
 APU_CHECK_DBD_ORACLE
 APU_CHECK_DBD_FREETDS
-dnl Enable DSO build; must be last:
-APU_CHECK_DBD_DSO
 APU_FIND_EXPAT
 APU_FIND_ICONV
 
+dnl Enable DSO build; must be last:
+APU_CHECK_DBD_DSO
+
 AC_SEARCH_LIBS(crypt, crypt ufc)
 AC_MSG_CHECKING(if system crypt() function is threadsafe)
 if test "x$apu_crypt_threadsafe" = "x1"; then

Modified: apr/apr-util/branches/1.3.x/dbd/apr_dbd.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/dbd/apr_dbd.c?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/dbd/apr_dbd.c (original)
+++ apr/apr-util/branches/1.3.x/dbd/apr_dbd.c Thu May 22 15:37:47 2008
@@ -38,6 +38,8 @@
 /* deprecated, but required for existing providers.  Existing and new
  * providers should be refactored to use a provider-specific mutex so
  * that different providers do not block one another. 
+ * In APR 1.3 this is no longer used for dso module loading, and
+ * apu_dso_mutex_[un]lock is used instead.
  * In APR 2.0 this should become entirely local to libaprutil-2.so and
  * no longer be exported.
  */
@@ -84,14 +86,20 @@
 APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool)
 {
     apr_status_t ret = APR_SUCCESS;
+    apr_pool_t *parent;
 
     if (drivers != NULL) {
         return APR_SUCCESS;
     }
-    drivers = apr_hash_make(pool);
-    apr_pool_cleanup_register(pool, NULL, apr_dbd_term,
-                              apr_pool_cleanup_null);
 
+    /* Top level pool scope, need process-scope lifetime */
+    for ( ; parent = apr_pool_parent_get(pool); parent)
+         pool = parent;
+
+    /* deprecate in 2.0 - permit implicit initialization */
+    apu_dso_init(pool);
+
+    drivers = apr_hash_make(pool);
 
 #if APR_HAS_THREADS
     ret = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, pool);
@@ -120,35 +128,30 @@
 #endif
 #endif /* APU_DSO_BUILD */
 
+    apr_pool_cleanup_register(pool, NULL, apr_dbd_term,
+                              apr_pool_cleanup_null);
+
     return ret;
 }
 
-#if defined(APU_DSO_BUILD) && APR_HAS_THREADS
-#define dbd_drivers_lock(m) apr_thread_mutex_lock(m)
-#define dbd_drivers_unlock(m) apr_thread_mutex_unlock(m)
-#else
-#define dbd_drivers_lock(m) APR_SUCCESS
-#define dbd_drivers_unlock(m)
-#endif
-
 APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name,
                                              const apr_dbd_driver_t **driver)
 {
 #ifdef APU_DSO_BUILD
-    char path[APR_PATH_MAX + 1];
-    apr_dso_handle_t *dlhandle = NULL;
+    char modname[32];
+    char symname[34];
     apr_dso_handle_sym_t symbol;
 #endif
     apr_status_t rv;
 
-    rv = dbd_drivers_lock(mutex);
+    rv = apu_dso_mutex_lock();
     if (rv) {
-        return APR_SUCCESS;
+        return rv;
     }
 
-   *driver = apr_hash_get(drivers, name, APR_HASH_KEY_STRING);
+    *driver = apr_hash_get(drivers, name, APR_HASH_KEY_STRING);
     if (*driver) {
-        dbd_drivers_unlock(mutex);
+        apu_dso_mutex_unlock();
         return APR_SUCCESS;
     }
 
@@ -157,31 +160,33 @@
      * drivers hash table; ignore the passed-in pool */
     pool = apr_hash_pool_get(drivers);
 
-#ifdef WIN32
-    apr_snprintf(path, sizeof path, "apr_dbd_%s.dll", name);
-#elif defined(NETWARE)
-    apr_snprintf(path, sizeof path, "dbd%s.nlm", name);
+#if defined(NETWARE)
+    apr_snprintf(modname, sizeof(modname), "dbd%s.nlm", name);
+#elif defined(WIN32)
+    apr_snprintf(modname, sizeof(modname), 
+                 "apr_dbd_%s-" APU_STRINGIFY(APU_MAJOR_VERSION) ".dll", name);
 #else
-    apr_snprintf(path, sizeof path, "%s/apr_dbd_%s.so", APU_DSO_LIBDIR, name);
+    apr_snprintf(modname, sizeof(modname), 
+                 "apr_dbd_%s-" APU_STRINGIFY(APU_MAJOR_VERSION) ".so", name);
 #endif
-    rv = apr_dso_load(&dlhandle, path, pool);
-    if (rv != APR_SUCCESS) { /* APR_EDSOOPEN */
-        goto unlock;
-    }
-    apr_snprintf(path, sizeof path, "apr_dbd_%s_driver", name);
-    rv = apr_dso_sym(&symbol, dlhandle, path);
-    if (rv != APR_SUCCESS) { /* APR_ESYMNOTFOUND */
-        apr_dso_unload(dlhandle);
+    apr_snprintf(symname, sizeof(symname), "apr_dbd_%s_driver", name);
+    rv = apu_dso_load(&symbol, modname, symname, pool);
+    if (rv != APR_SUCCESS) { /* APR_EDSOOPEN or APR_ESYMNOTFOUND? */
+        if (rv == APR_EINIT) { /* previously loaded?!? */
+            apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
+            rv = APR_SUCCESS;
+        }
         goto unlock;
     }
     *driver = symbol;
     if ((*driver)->init) {
         (*driver)->init(pool);
     }
+    name = apr_pstrdup(pool, name);
     apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
 
 unlock:
-    dbd_drivers_unlock(mutex);
+    apu_dso_mutex_unlock();
 
 #else /* not builtin and !APR_HAS_DSO => not implemented */
     rv = APR_ENOTIMPL;

Modified: apr/apr-util/branches/1.3.x/include/apr_ldap.h.in
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/include/apr_ldap.h.in?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/include/apr_ldap.h.in (original)
+++ apr/apr-util/branches/1.3.x/include/apr_ldap.h.in Thu May 22 15:37:47 2008
@@ -153,7 +153,27 @@
 
 #define APR_LDAP_IS_SERVER_DOWN(s)                ((s) == LDAP_SERVER_DOWN)
 
+/* These symbols are not actually exported in a DSO build, but mapped into
+ * a private exported function array for apr_ldap_stub to bind dynamically.
+ * Rename them appropriately to protect the global namespace.
+ */
+#ifdef APU_DSO_LDAP_BUILD
+
+#define apr_ldap_info apr__ldap_info
+#define apr_ldap_init apr__ldap_init
+#define apr_ldap_ssl_init apr__ldap_ssl_init
+#define apr_ldap_ssl_deinit apr__ldap_ssl_deinit
+#define apr_ldap_get_option apr__ldap_get_option
+#define apr_ldap_set_option apr__ldap_set_option
+#define apr_ldap_rebind_init apr__ldap_rebind_init
+#define apr_ldap_rebind_add apr__ldap_rebind_add
+#define apr_ldap_rebind_remove apr__ldap_rebind_remove
+
+#define APU_DECLARE_LDAP(type) type
+#else
 #define APU_DECLARE_LDAP(type) APU_DECLARE(type)
+#endif
+
 #include "apr_ldap_url.h"
 #include "apr_ldap_init.h"
 #include "apr_ldap_option.h"

Modified: apr/apr-util/branches/1.3.x/include/apr_ldap.hnw
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/include/apr_ldap.hnw?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/include/apr_ldap.hnw (original)
+++ apr/apr-util/branches/1.3.x/include/apr_ldap.hnw Thu May 22 15:37:47 2008
@@ -126,7 +126,27 @@
 
 #define APR_LDAP_IS_SERVER_DOWN(s)                ((s) == LDAP_SERVER_DOWN)
 
+/* These symbols are not actually exported in a DSO build, but mapped into
+ * a private exported function array for apr_ldap_stub to bind dynamically.
+ * Rename them appropriately to protect the global namespace.
+ */
+#ifdef APU_DSO_LDAP_BUILD
+
+#define apr_ldap_info apr__ldap_info
+#define apr_ldap_init apr__ldap_init
+#define apr_ldap_ssl_init apr__ldap_ssl_init
+#define apr_ldap_ssl_deinit apr__ldap_ssl_deinit
+#define apr_ldap_get_option apr__ldap_get_option
+#define apr_ldap_set_option apr__ldap_set_option
+#define apr_ldap_rebind_init apr__ldap_rebind_init
+#define apr_ldap_rebind_add apr__ldap_rebind_add
+#define apr_ldap_rebind_remove apr__ldap_rebind_remove
+
+#define APU_DECLARE_LDAP(type) type
+#else
 #define APU_DECLARE_LDAP(type) APU_DECLARE(type)
+#endif
+
 #include "apr_ldap_url.h"
 #include "apr_ldap_init.h"
 #include "apr_ldap_option.h"

Modified: apr/apr-util/branches/1.3.x/include/apr_ldap.hw
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/include/apr_ldap.hw?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/include/apr_ldap.hw (original)
+++ apr/apr-util/branches/1.3.x/include/apr_ldap.hw Thu May 22 15:37:47 2008
@@ -134,7 +134,27 @@
 #define APR_LDAP_IS_SERVER_DOWN(s) ((s) == LDAP_SERVER_DOWN)
 #endif
 
+/* These symbols are not actually exported in a DSO build, but mapped into
+ * a private exported function array for apr_ldap_stub to bind dynamically.
+ * Rename them appropriately to protect the global namespace.
+ */
+#ifdef APU_DSO_LDAP_BUILD
+
+#define apr_ldap_info apr__ldap_info
+#define apr_ldap_init apr__ldap_init
+#define apr_ldap_ssl_init apr__ldap_ssl_init
+#define apr_ldap_ssl_deinit apr__ldap_ssl_deinit
+#define apr_ldap_get_option apr__ldap_get_option
+#define apr_ldap_set_option apr__ldap_set_option
+#define apr_ldap_rebind_init apr__ldap_rebind_init
+#define apr_ldap_rebind_add apr__ldap_rebind_add
+#define apr_ldap_rebind_remove apr__ldap_rebind_remove
+
+#define APU_DECLARE_LDAP(type) type
+#else
 #define APU_DECLARE_LDAP(type) APU_DECLARE(type)
+#endif
+
 #include "apr_ldap_url.h"
 #include "apr_ldap_init.h"
 #include "apr_ldap_option.h"

Added: apr/apr-util/branches/1.3.x/include/private/apu_internal.h
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/include/private/apu_internal.h?rev=659294&view=auto
==============================================================================
--- apr/apr-util/branches/1.3.x/include/private/apu_internal.h (added)
+++ apr/apr-util/branches/1.3.x/include/private/apu_internal.h Thu May 22 15:37:47 2008
@@ -0,0 +1,71 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_dso.h"
+#include "apu.h"
+
+#ifndef APU_INTERNAL_H
+#define APU_INTERNAL_H
+
+#if APU_DSO_BUILD
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For modular dso loading, an internal interlock to allow us to
+ * continue to initialize modules by multiple threads, the caller
+ * of apu_dso_load must lock first, and not unlock until any init
+ * finalization is complete.
+ */ 
+apr_status_t apu_dso_mutex_lock(void);
+apr_status_t apu_dso_mutex_unlock(void);
+
+apr_status_t apu_dso_load(apr_dso_handle_sym_t *dsoptr, const char *module,
+                          const char *modsym, apr_pool_t *pool);
+
+#if APR_HAS_LDAP
+
+/* For LDAP internal builds, wrap our LDAP namespace */
+
+struct apr__ldap_dso_fntable {
+    int (*info)(apr_pool_t *pool, apr_ldap_err_t **result_err);
+    int (*init)(apr_pool_t *pool, LDAP **ldap, const char *hostname,
+                int portno, int secure, apr_ldap_err_t **result_err);
+    int (*ssl_init)(apr_pool_t *pool, const char *cert_auth_file,
+                    int cert_file_type, apr_ldap_err_t **result_err);
+    int (*ssl_deinit)(void);
+    int (*get_option)(apr_pool_t *pool, LDAP *ldap, int option,
+                      void *outvalue, apr_ldap_err_t **result_err);
+    int (*set_option)(apr_pool_t *pool, LDAP *ldap, int option,
+                      const void *invalue, apr_ldap_err_t **result_err);
+    apr_status_t (*rebind_init)(apr_pool_t *pool);
+    apr_status_t (*rebind_add)(apr_pool_t *pool, LDAP *ld,
+                               const char *bindDN, const char *bindPW);
+    apr_status_t (*rebind_remove)(LDAP *ld);
+};
+
+#endif /* APR_HAS_LDAP */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* APU_DSO_BUILD */
+
+#endif /* APU_INTERNAL_H */
+

Propchange: apr/apr-util/branches/1.3.x/include/private/apu_internal.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: apr/apr-util/branches/1.3.x/ldap/apr_ldap_init.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/ldap/apr_ldap_init.c?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/ldap/apr_ldap_init.c (original)
+++ apr/apr-util/branches/1.3.x/ldap/apr_ldap_init.c Thu May 22 15:37:47 2008
@@ -31,6 +31,7 @@
 #endif
 
 #include "apr_ldap.h"
+#include "apu_internal.h"
 #include "apr_errno.h"
 #include "apr_pools.h"
 #include "apr_strings.h"
@@ -196,4 +197,23 @@
     
 }
 
+#if APU_DSO_BUILD
+
+/* For DSO builds, export the table of entry points into the apr_ldap DSO
+ * See include/private/apu_internal.h for the corresponding declarations
+ */
+APU_DECLARE_DATA struct apr__ldap_dso_fntable apr__ldap_fns = {
+    apr_ldap_info,
+    apr_ldap_init,
+    apr_ldap_ssl_init,
+    apr_ldap_ssl_deinit,
+    apr_ldap_get_option,
+    apr_ldap_set_option,
+    apr_ldap_rebind_init,
+    apr_ldap_rebind_add,
+    apr_ldap_rebind_remove
+};
+
+#endif /* APU_DSO_BUILD */
+
 #endif /* APR_HAS_LDAP */

Added: apr/apr-util/branches/1.3.x/ldap/apr_ldap_stub.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/ldap/apr_ldap_stub.c?rev=659294&view=auto
==============================================================================
--- apr/apr-util/branches/1.3.x/ldap/apr_ldap_stub.c (added)
+++ apr/apr-util/branches/1.3.x/ldap/apr_ldap_stub.c Thu May 22 15:37:47 2008
@@ -0,0 +1,148 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apu.h"
+#include "apu_config.h"
+#include "apr_ldap.h"
+#include "apu_internal.h"
+#include "apr_dso.h"
+#include "apr_errno.h"
+#include "apr_pools.h"
+#include "apr_strings.h"
+#include "apu_version.h"
+
+#if APR_HAS_LDAP
+
+#if APU_DSO_BUILD
+
+static struct apr__ldap_dso_fntable *lfn = NULL;
+
+static apr_status_t load_ldap(apr_pool_t *pool)
+{
+    char *modname;
+    apr_dso_handle_sym_t symbol;
+    apr_status_t rv;
+    apr_pool_t *parent;
+
+    /* deprecate in 2.0 - permit implicit initialization */
+    apu_dso_init(pool);
+
+    rv = apu_dso_mutex_lock();
+    if (rv) {
+        return rv;
+    }
+
+#if defined(NETWARE)
+    modname = "aprldap.nlm";
+#elif defined(WIN32)
+    modname = "apr_ldap-" APU_STRINGIFY(APU_MAJOR_VERSION) ".dll";
+#else
+    modname = "apr_ldap-" APU_STRINGIFY(APU_MAJOR_VERSION) ".so";
+#endif
+    rv = apu_dso_load(&symbol, modname, "apr__ldap_fns", pool);
+    if (rv == APR_SUCCESS) {
+        lfn = symbol;
+    }
+    apu_dso_mutex_unlock();
+
+    return rv;
+}
+
+#define LOAD_LDAP_STUB(pool, failres) \
+    if (!lfn && (load_ldap(pool) != APR_SUCCESS)) \
+        return failres;
+
+APU_DECLARE_LDAP(int) apr_ldap_info(apr_pool_t *pool,
+                                    apr_ldap_err_t **result_err)
+{
+    LOAD_LDAP_STUB(pool, -1);
+    return lfn->info(pool, result_err);
+}
+
+APU_DECLARE_LDAP(int) apr_ldap_init(apr_pool_t *pool,
+                                    LDAP **ldap,
+                                    const char *hostname,
+                                    int portno,
+                                    int secure,
+                                    apr_ldap_err_t **result_err)
+{
+    LOAD_LDAP_STUB(pool, -1);
+    return lfn->init(pool, ldap, hostname, portno, secure, result_err);
+}
+
+APU_DECLARE_LDAP(int) apr_ldap_ssl_init(apr_pool_t *pool,
+                                        const char *cert_auth_file,
+                                        int cert_file_type,
+                                        apr_ldap_err_t **result_err)
+{
+    LOAD_LDAP_STUB(pool, -1);
+    return lfn->ssl_init(pool, cert_auth_file, cert_file_type, result_err);
+}
+
+APU_DECLARE_LDAP(int) apr_ldap_ssl_deinit(void)
+{
+    if (!lfn)
+        return -1;
+    return lfn->ssl_deinit();
+}
+
+APU_DECLARE_LDAP(int) apr_ldap_get_option(apr_pool_t *pool,
+                                          LDAP *ldap,
+                                          int option,
+                                          void *outvalue,
+                                          apr_ldap_err_t **result_err)
+{
+    LOAD_LDAP_STUB(pool, -1);
+    return lfn->get_option(pool, ldap, option, outvalue, result_err);
+}
+
+APU_DECLARE_LDAP(int) apr_ldap_set_option(apr_pool_t *pool,
+                                          LDAP *ldap,
+                                          int option,
+                                          const void *invalue,
+                                          apr_ldap_err_t **result_err)
+{
+    LOAD_LDAP_STUB(pool, -1);
+    return lfn->set_option(pool, ldap, option, invalue, result_err);
+}
+
+APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_init(apr_pool_t *pool)
+{
+    LOAD_LDAP_STUB(pool, APR_EGENERAL);
+    return lfn->rebind_init(pool);
+}
+
+APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_add(apr_pool_t *pool,
+                                                   LDAP *ld,
+                                                   const char *bindDN,
+                                                   const char *bindPW)
+{
+    LOAD_LDAP_STUB(pool, APR_EGENERAL);
+    return lfn->rebind_add(pool, ld, bindDN, bindPW);
+}
+
+APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_remove(LDAP *ld)
+{
+    if (!lfn)
+        return APR_EGENERAL;
+    return lfn->rebind_remove(ld);
+}
+
+#endif /* APU_DSO_BUILD */
+
+#endif /* APR_HAS_LDAP */
+

Propchange: apr/apr-util/branches/1.3.x/ldap/apr_ldap_stub.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: apr/apr-util/branches/1.3.x/misc/apu_dso.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/misc/apu_dso.c?rev=659294&view=auto
==============================================================================
--- apr/apr-util/branches/1.3.x/misc/apu_dso.c (added)
+++ apr/apr-util/branches/1.3.x/misc/apu_dso.c Thu May 22 15:37:47 2008
@@ -0,0 +1,175 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+
+#include "apu_config.h"
+#include "apu.h"
+
+#include "apr_pools.h"
+#include "apr_tables.h"
+#include "apr_dso.h"
+#include "apr_strings.h"
+#include "apr_hash.h"
+#include "apr_thread_mutex.h"
+
+#include "apr_dbd_internal.h"
+#include "apr_dbd.h"
+#include "apu_version.h"
+
+
+#if APR_HAS_THREADS
+static apr_thread_mutex_t* mutex = NULL;
+#endif
+static apr_hash_t *dsos = NULL;
+
+
+#if defined(APR_HAS_THREADS) && defined(APU_DSO_BUILD)
+apr_status_t apu_dso_mutex_lock()
+{
+    return apr_thread_mutex_lock(mutex);
+}
+apr_status_t apu_dso_mutex_unlock()
+{
+    return apr_thread_mutex_unlock(mutex);
+}
+#else
+apr_status_t apu_dso_mutex_lock() {
+    return APR_SUCCESS;
+}
+apr_status_t apu_dso_mutex_unlock() {
+    return APR_SUCCESS;
+}
+#endif
+
+#define CLEANUP_CAST (apr_status_t (*)(void*))
+
+
+static apr_status_t apu_dso_term(void *ptr)
+{
+    /* set statics to NULL so init can work again */
+    dsos = NULL;
+#if APR_HAS_THREADS
+    mutex = NULL;
+#endif
+
+    /* Everything else we need is handled by cleanups registered
+     * when we created mutexes and loaded DSOs
+     */
+    return APR_SUCCESS;
+}
+
+APU_DECLARE(apr_status_t) apu_dso_init(apr_pool_t *pool)
+{
+    apr_status_t ret = APR_SUCCESS;
+    apr_pool_t *global;
+    apr_pool_t *parent;
+
+#ifdef APU_DSO_BUILD
+    /* Top level pool scope, need process-scope lifetime */
+    for (global = pool; parent = apr_pool_parent_get(global); parent)
+         global = parent;
+
+    if (dsos != NULL) {
+        return APR_SUCCESS;
+    }
+    dsos = apr_hash_make(global);
+
+#if APR_HAS_THREADS
+    ret = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, global);
+    /* This already registers a pool cleanup */
+#endif
+
+    apr_pool_cleanup_register(global, NULL, apu_dso_term,
+                              apr_pool_cleanup_null);
+
+#endif /* APU_DSO_BUILD */
+    return ret;
+}
+
+apr_status_t apu_dso_load(apr_dso_handle_sym_t *dsoptr, const char *module,
+                          const char *modsym, apr_pool_t *pool)
+{
+#ifndef APU_DSO_BUILD
+    return APR_ENOTIMPL;
+#else
+    apr_dso_handle_t *dlhandle = NULL;
+    char *pathlist;
+    char path[APR_PATH_MAX + 1];
+    apr_array_header_t *paths;
+    apr_pool_t *global;
+    apr_status_t rv;
+    char *eos = NULL;
+    int i;
+
+    *dsoptr = apr_hash_get(dsos, module, APR_HASH_KEY_STRING);
+    if (*dsoptr) {
+        return APR_EINIT;
+    }
+
+    /* The driver DSO must have exactly the same lifetime as the
+     * drivers hash table; ignore the passed-in pool */
+    global = apr_hash_pool_get(dsos);
+
+    /* Retrieve our path search list or prepare for a single search */
+    if ((apr_env_get(&pathlist, APR_DSOPATH, pool) != APR_SUCCESS)
+          || (apr_filepath_list_split(&paths, pathlist, pool) != APR_SUCCESS))
+        paths = apr_array_make(pool, 1, sizeof(char*));
+
+    /* Always search our prefix path */
+    (*((char **)apr_array_push(paths))) = APU_DSO_LIBDIR;
+
+    for (i = 0; i < paths->nelts; ++i)
+    {
+#if defined(WIN32)
+        /* Use win32 dso search semantics and attempt to
+         * load the relative lib on the first pass.
+         */
+        if (!eos) {
+            eos = path;
+            --i;
+        }
+        else
+#endif
+        {
+            eos = apr_cpystrn(path, ((char**)paths->elts)[i], sizeof(path));
+            if ((eos > path) && (eos - path < sizeof(path) - 1))
+                *(eos++) = '/';
+        }
+        apr_cpystrn(eos, module, sizeof(path) - (eos - path));
+
+        rv = apr_dso_load(&dlhandle, path, global);
+        if (rv == APR_SUCCESS) { /* APR_EDSOOPEN */
+            break;
+        }
+    }
+
+    if (rv != APR_SUCCESS) /* APR_ESYMNOTFOUND */
+        return rv;
+
+    rv = apr_dso_sym(dsoptr, dlhandle, modsym);
+    if (rv != APR_SUCCESS) { /* APR_ESYMNOTFOUND */
+        apr_dso_unload(dlhandle);
+    }
+    else {
+        module = apr_pstrdup(global, module);
+        apr_hash_set(dsos, module, APR_HASH_KEY_STRING, *dsoptr);
+    }
+    return rv;
+#endif /* APU_DSO_BUILD */
+}
+

Propchange: apr/apr-util/branches/1.3.x/misc/apu_dso.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: apr/apr-util/branches/1.3.x/test/Makefile.in
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/test/Makefile.in?rev=659294&r1=659293&r2=659294&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/test/Makefile.in (original)
+++ apr/apr-util/branches/1.3.x/test/Makefile.in Thu May 22 15:37:47 2008
@@ -47,7 +47,7 @@
 
 OBJECTS_testall = abts.lo testutil.lo $(TESTS) $(LOCAL_LIBS)
 testall: $(OBJECTS_testall)
-	$(LINK_PROG) $(OBJECTS_testall) $(APRUTIL_LIBS)
+	$(LINK_PROG) $(OBJECTS_testall) $(APRUTIL_LIBS) @LDADD_ldap@
 # For VPATH builds; where we have no ./data, copy us some data
 # if we wait until 'make check', then 'make; ./testall' fails;
 	if test ! -d "./data"; then cp -r $(srcdir)/data data; fi
@@ -62,6 +62,7 @@
 	for prog in $(STDTEST_PORTABLE) $(STDTEST_NONPORTABLE); do \
 	        if test "$$prog" = 'dbd'; then \
 			for driver in sqlite2 sqlite3; do \
+				@apr_shlibpath_var@="`echo "../dbd/.libs:../ldap/.libs:$$@apr_shlibpath_var@" | sed -e
's/::*$$//'`" \
 				./$$prog $$driver; \
 				status=$$?; \
 				if test $$status != 0; then \
@@ -70,6 +71,7 @@
 				fi; \
 			done; \
 	        else \
+			@apr_shlibpath_var@="`echo "../dbd/.libs:../ldap/.libs:$$@apr_shlibpath_var@" | sed -e
's/::*$$//'`" \
 			./$$prog; \
 			status=$$?; \
 			if test $$status != 0; then \



Mime
View raw message