From commits-return-9993-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Fri Nov 21 04:06:07 2008 Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 649 invoked from network); 21 Nov 2008 04:06:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2008 04:06:07 -0000 Received: (qmail 3125 invoked by uid 500); 21 Nov 2008 04:06:16 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 3100 invoked by uid 500); 21 Nov 2008 04:06:16 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 3091 invoked by uid 99); 21 Nov 2008 04:06:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Nov 2008 20:06:16 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Nov 2008 04:04:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 90F2E2388873; Thu, 20 Nov 2008 20:05:09 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r719467 - in /apr/apr-util/trunk: Makefile.in build.conf build/dbm.m4 build/dso.m4 dbm/apr_dbm.c dbm/apr_dbm_berkeleydb.c dbm/apr_dbm_gdbm.c dbm/apr_dbm_ndbm.c include/apr_dbm.h include/apu.hw include/private/apr_dbm_private.h Date: Fri, 21 Nov 2008 04:05:08 -0000 To: commits@apr.apache.org From: wrowe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081121040509.90F2E2388873@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wrowe Date: Thu Nov 20 20:05:08 2008 New Revision: 719467 URL: http://svn.apache.org/viewvc?rev=719467&view=rev Log: replace missing comment Modified: apr/apr-util/trunk/Makefile.in apr/apr-util/trunk/build.conf apr/apr-util/trunk/build/dbm.m4 apr/apr-util/trunk/build/dso.m4 apr/apr-util/trunk/dbm/apr_dbm.c apr/apr-util/trunk/dbm/apr_dbm_berkeleydb.c apr/apr-util/trunk/dbm/apr_dbm_gdbm.c apr/apr-util/trunk/dbm/apr_dbm_ndbm.c apr/apr-util/trunk/include/apr_dbm.h apr/apr-util/trunk/include/apu.hw apr/apr-util/trunk/include/private/apr_dbm_private.h Modified: apr/apr-util/trunk/Makefile.in URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/Makefile.in?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/Makefile.in (original) +++ apr/apr-util/trunk/Makefile.in Thu Nov 20 20:05:08 2008 @@ -37,6 +37,9 @@ LDADD_dbd_mysql = @LDADD_dbd_mysql@ LDADD_dbd_freetds = @LDADD_dbd_freetds@ LDADD_dbd_odbc = @LDADD_dbd_odbc@ +LDADD_dbm_db = @LDADD_dbm_db@ +LDADD_dbm_gdbm = @LDADD_dbm_gdbm@ +LDADD_dbm_ndbm = @LDADD_dbm_ndbm@ LDADD_ldap = @LDADD_ldap@ LDADD_crypto_openssl = @LDADD_crypto_openssl@ LDADD_crypto_nss = @LDADD_crypto_nss@ Modified: apr/apr-util/trunk/build.conf URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/build.conf?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/build.conf (original) +++ apr/apr-util/trunk/build.conf Thu Nov 20 20:05:08 2008 @@ -13,7 +13,8 @@ crypto/apr_sha1.c crypto/getuuid.c crypto/uuid.c - dbm/*.c + dbm/apr_dbm_sdbm.c + dbm/apr_dbm.c dbm/sdbm/*.c encoding/*.c hooks/*.c @@ -33,7 +34,10 @@ # the public headers headers = include/*.h include/private/*.h -modules = crypto_openssl crypto_nss ldap dbd_pgsql dbd_sqlite2 dbd_sqlite3 dbd_oracle dbd_mysql dbd_freetds dbd_odbc +modules = + ldap crypto_openssl crypto_nss dbd_pgsql + dbd_sqlite2 dbd_sqlite3 dbd_oracle dbd_mysql dbd_freetds dbd_odbc + dbm_db dbm_gdbm dbm_ndbm # gen_uri_delim.c @@ -76,8 +80,21 @@ paths = dbd/apr_dbd_odbc.c target = dbd/apr_dbd_odbc.la +[dbm_db] +paths = dbm/apr_dbm_berkeleydb.c +target = dbm/apr_dbm_db.la + +[dbm_gdbm] +paths = dbm/apr_dbm_gdbm.c +target = dbm/apr_dbm_gdbm.la + +[dbm_ndbm] +paths = dbm/apr_dbm_ndbm.c +target = dbm/apr_dbm_ndbm.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/trunk/build/dbm.m4 URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/build/dbm.m4?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/build/dbm.m4 (original) +++ apr/apr-util/trunk/build/dbm.m4 Thu Nov 20 20:05:08 2008 @@ -911,25 +911,25 @@ AC_SUBST(apu_db_header) AC_SUBST(apu_db_version) + if test "$apu_have_db" = "1"; then + LDADD_dbm_db="-l$apu_db_lib" + if test -n "apu_db_xtra_libs"; then + LDADD_dbm_db="$LDADD_dbm_db $apu_db_xtra_libs" + fi + fi + dnl Since we have already done the AC_CHECK_LIB tests, if we have it, dnl we know the library is there. if test "$apu_have_gdbm" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lgdbm]) - APR_ADDTO(APRUTIL_LIBS,[-lgdbm]) + LDADD_dbm_gdbm="-lgdbm" fi if test "$apu_have_ndbm" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_ndbm_lib]) - APR_ADDTO(APRUTIL_LIBS,[-l$apu_ndbm_lib]) + LDADD_dbm_ndbm="-l$apu_ndbm_lib" fi - if test "$apu_have_db" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_db_lib]) - APR_ADDTO(APRUTIL_LIBS,[-l$apu_db_lib]) - if test -n "apu_db_xtra_libs"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[$apu_db_xtra_libs]) - APR_ADDTO(APRUTIL_LIBS,[$apu_db_xtra_libs]) - fi - fi + AC_SUBST(LDADD_dbm_db) + AC_SUBST(LDADD_dbm_gdbm) + AC_SUBST(LDADD_dbm_ndbm) ]) Modified: apr/apr-util/trunk/build/dso.m4 URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/build/dso.m4?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/build/dso.m4 (original) +++ apr/apr-util/trunk/build/dso.m4 Thu Nov 20 20:05:08 2008 @@ -28,6 +28,7 @@ aprdso=`awk '/^#define APR_HAS_DSO/ { print @S|@3; }' $apr_h` if test "$enable_util_dso" = "no" || "$aprdso" = "0"; then + # Statically link the DBD drivers: objs= test $apu_have_openssl = 1 && objs="$objs crypto/apr_crypto_openssl.lo" Modified: apr/apr-util/trunk/dbm/apr_dbm.c URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbm/apr_dbm.c?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/dbm/apr_dbm.c (original) +++ apr/apr-util/trunk/dbm/apr_dbm.c Thu Nov 20 20:05:08 2008 @@ -34,56 +34,165 @@ ### API entirely? Oh, what to do. We need an APU_DEFAULT_DBM #define. ### Sounds like a job for autoconf. */ -#if APU_USE_SDBM -#define DBM_VTABLE apr_dbm_type_sdbm +#if APU_USE_DB +#define DBM_VTABLE apr_dbm_type_db +#define DBM_NAME "db" #elif APU_USE_GDBM #define DBM_VTABLE apr_dbm_type_gdbm -#elif APU_USE_DB -#define DBM_VTABLE apr_dbm_type_db +#define DBM_NAME "gdbm" #elif APU_USE_NDBM #define DBM_VTABLE apr_dbm_type_ndbm +#define DBM_NAME "ndbm" +#elif APU_USE_SDBM +#define DBM_VTABLE apr_dbm_type_sdbm +#define DBM_NAME "sdbm" #else /* Not in the USE_xDBM list above */ #error a DBM implementation was not specified #endif -APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **pdb, const char*type, - const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool) +#ifdef APU_DSO_BUILD + +static apr_hash_t *drivers = NULL; + +static apr_status_t apr_dbd_term(void *ptr) { + /* set drivers to NULL so init can work again */ + drivers = NULL; + + /* Everything else we need is handled by cleanups registered + * when we created mutexes and loaded DSOs + */ + return APR_SUCCESS; +} + +#endif /* APU_DSO_BUILD */ + +static apr_status_t dbm_open_type(apr_dbm_type_t const* * vtable, + const char *type, + apr_pool_t *pool) +{ +#ifndef APU_DSO_BUILD + + *vtable = NULL; + if (!strcasecmp(type, "default")) *vtable = &DBM_VTABLE; +#if APU_HAVE_DB + else if (!strcasecmp(type, "db")) *vtable = &apr_dbm_type_db; +#endif + else if (*type && !strcasecmp(type + 1, "dbm")) { #if APU_HAVE_GDBM - if (!strcasecmp(type, "GDBM")) { - return (*apr_dbm_type_gdbm.open)(pdb, pathname, mode, perm, pool); - } + if (*type == 'G' && *type == 'g') *vtable = &apr_dbm_type_gdbm; +#endif +#if APU_HAVE_NDBM + if (*type == 'N' && *type == 'n') *vtable = &apr_dbm_type_ndbm; #endif #if APU_HAVE_SDBM - if (!strcasecmp(type, "SDBM")) { - return (*apr_dbm_type_sdbm.open)(pdb, pathname, mode, perm, pool); - } + if (*type == 'S' && *type == 's') *vtable = &apr_dbm_type_sdbm; #endif -#if APU_HAVE_DB - if (!strcasecmp(type, "DB")) { - return (*apr_dbm_type_db.open)(pdb, pathname, mode, perm, pool); + /* avoid empty block */ ; } -#endif -#if APU_HAVE_NDBM - if (!strcasecmp(type, "NDBM")) { - return (*apr_dbm_type_ndbm.open)(pdb, pathname, mode, perm, pool); + if (*vtable) + return APR_SUCCESS; + return APR_ENOTIMPL; + +#else /* APU_DSO_BUILD */ + + char modname[32]; + char symname[34]; + apr_dso_handle_sym_t symbol; + apr_status_t rv; + int usertype = 0; + + if (!strcasecmp(type, "default")) type = DBM_NAME; + else if (!strcasecmp(type, "db")) type = "db"; + else if (*type && !strcasecmp(type + 1, "dbm")) { + if (type == 'G' || type == 'g') type = "gdbm"; + else if (type == 'N' || type == 'n') type = "ndbm"; + else if (type == 'S' || type == 's') type = "sdbm"; + } + else usertype = 1; + + if (!drivers) + { + apr_pool_t *ppool = pool; + apr_pool_t *parent; + + /* Top level pool scope, need process-scope lifetime */ + for (parent = pool; parent; parent = apr_pool_parent_get(ppool)) + ppool = parent; + + /* deprecate in 2.0 - permit implicit initialization */ + apu_dso_init(ppool); + + drivers = apr_hash_make(ppool); + apr_hash_set(drivers, "sdbm", APR_HASH_KEY_STRING, &apr_dbm_type_sdbm); + + apr_pool_cleanup_register(ppool, NULL, dbm_term, + apr_pool_cleanup_null); } + + rv = apu_dso_mutex_lock(); + if (rv) { + *vtable = NULL + return rv; + } + + *vtable = apr_hash_get(drivers, type, APR_HASH_KEY_STRING); + if (*vtable) { + apu_dso_mutex_unlock(); + return APR_SUCCESS; + } + + /* The driver DSO must have exactly the same lifetime as the + * drivers hash table; ignore the passed-in pool */ + pool = apr_hash_pool_get(drivers); + +#if defined(NETWARE) + apr_snprintf(modname, sizeof(modname), "dbm%s.nlm", type); +#elif defined(WIN32) + apr_snprintf(modname, sizeof(modname), + "apr_dbm_%s-" APU_STRINGIFY(APU_MAJOR_VERSION) ".dll", type); +#else + apr_snprintf(modname, sizeof(modname), + "apr_dbm_%s-" APU_STRINGIFY(APU_MAJOR_VERSION) ".so", type); #endif + apr_snprintf(symname, sizeof(symname), "apr_dbm_type_%s", type); - if (!strcasecmp(type, "default")) { - return (*DBM_VTABLE.open)(pdb, pathname, mode, perm, pool); + rv = apu_dso_load(&symbol, modname, symname, pool); + if (rv != APR_SUCCESS || rv == APR_EINIT) { /* previously loaded?!? */ + *vtable = symbol; + if (usertype) + type = apr_pstrdup(pool, type); + apr_hash_set(drivers, type, APR_HASH_KEY_STRING, *vtable); } + else + *vtable = NULL; - return APR_ENOTIMPL; + apu_dso_mutex_unlock(); + return rv; + +#endif /* APU_DSO_BUILD */ +} + +APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **pdb, const char *type, + const char *pathname, + apr_int32_t mode, + apr_fileperms_t perm, + apr_pool_t *pool) +{ + apr_dbm_type_t const* vtable = NULL; + apr_status_t rv = dbm_open_type(&vtable, type, pool); + + if (rv == APR_SUCCESS) { + rv = (vtable->open)(pdb, pathname, mode, perm, pool); + } + return rv; } APU_DECLARE(apr_status_t) apr_dbm_open(apr_dbm_t **pdb, const char *pathname, apr_int32_t mode, apr_fileperms_t perm, apr_pool_t *pool) { - return (*DBM_VTABLE.open)(pdb, pathname, mode, perm, pool); + return apr_dbm_open_ex(pdb, DBM_NAME, pathname, mode, perm, pool); } APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm) @@ -149,37 +258,14 @@ const char **used1, const char **used2) { -#if APU_HAVE_GDBM - if (!strcasecmp(type, "GDBM")) { - (*apr_dbm_type_gdbm.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif -#if APU_HAVE_SDBM - if (!strcasecmp(type, "SDBM")) { - (*apr_dbm_type_sdbm.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif -#if APU_HAVE_DB - if (!strcasecmp(type, "DB")) { - (*apr_dbm_type_db.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif -#if APU_HAVE_NDBM - if (!strcasecmp(type, "NDBM")) { - (*apr_dbm_type_ndbm.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif + apr_dbm_type_t const* vtable; + apr_status_t rv = dbm_open_type(&vtable, type, p); - if (!strcasecmp(type, "default")) { - (*DBM_VTABLE.getusednames)(p, pathname, used1, used2); + if (rv == APR_SUCCESS) { + (vtable->getusednames)(p, pathname, used1, used2); return APR_SUCCESS; } - - return APR_ENOTIMPL; + return rv; } APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *p, @@ -187,10 +273,7 @@ const char **used1, const char **used2) { - /* ### one day, a DBM type name will be passed and we'll need to look it - ### up. for now, it is constant. */ - - (*DBM_VTABLE.getusednames)(p, pathname, used1, used2); + apr_dbm_get_usednames_ex(p, DBM_NAME, pathname, used1, used2); } /* Most DBM libraries take a POSIX mode for creating files. Don't trust Modified: apr/apr-util/trunk/dbm/apr_dbm_berkeleydb.c URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbm/apr_dbm_berkeleydb.c?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/dbm/apr_dbm_berkeleydb.c (original) +++ apr/apr-util/trunk/dbm/apr_dbm_berkeleydb.c Thu Nov 20 20:05:08 2008 @@ -385,7 +385,7 @@ } -APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_db = { +APU_MODULE_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_db = { "db", vt_db_open, Modified: apr/apr-util/trunk/dbm/apr_dbm_gdbm.c URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbm/apr_dbm_gdbm.c?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/dbm/apr_dbm_gdbm.c (original) +++ apr/apr-util/trunk/dbm/apr_dbm_gdbm.c Thu Nov 20 20:05:08 2008 @@ -237,7 +237,7 @@ *used2 = NULL; } -APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_gdbm = { +APU_MODULE_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_gdbm = { "gdbm", vt_gdbm_open, vt_gdbm_close, Modified: apr/apr-util/trunk/dbm/apr_dbm_ndbm.c URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbm/apr_dbm_ndbm.c?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/dbm/apr_dbm_ndbm.c (original) +++ apr/apr-util/trunk/dbm/apr_dbm_ndbm.c Thu Nov 20 20:05:08 2008 @@ -220,7 +220,7 @@ *used2 = NULL; } -APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_ndbm = { +APU_MODULE_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_ndbm = { "ndbm", vt_ndbm_open, vt_ndbm_close, Modified: apr/apr-util/trunk/include/apr_dbm.h URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apr_dbm.h?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/include/apr_dbm.h (original) +++ apr/apr-util/trunk/include/apr_dbm.h Thu Nov 20 20:05:08 2008 @@ -63,10 +63,10 @@ * @param dbm The newly opened database * @param type The type of the DBM (not all may be available at run time) *
- *  GDBM for GDBM files
- *  SDBM for SDBM files
- *  DB   for berkeley DB files
- *  NDBM for NDBM files
+ *  db   for Berkeley DB files
+ *  gdbm for GDBM files
+ *  ndbm for NDBM files
+ *  sdbm for SDBM files (always available)
  *  default for the default DBM type
  *  
* @param name The dbm file name to open @@ -81,6 +81,9 @@ * @param cntxt The pool to use when creating the dbm * @remark The dbm name may not be a true file name, as many dbm packages * append suffixes for seperate data and index files. + * @bug In apr-util 0.9 and 1.x, the type arg was case insensitive. This + * was highly inefficient, and as of 2.x the dbm name must be provided in + * the correct case (lower case for all bundled providers) */ APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **dbm, const char* type, @@ -184,7 +187,7 @@ * actual file/path names which would be (created and) used. At most, two * files may be used; used2 may be NULL if only one file is used. * @param pool The pool for allocating used1 and used2. - * @param type The type of DBM you require info on + * @param type The type of DBM you require info on @see apr_dbm_open_ex * @param pathname The path name to generate used-names from. * @param used1 The first pathname used by the apr_dbm implementation. * @param used2 The second pathname used by apr_dbm. If only one file is Modified: apr/apr-util/trunk/include/apu.hw URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apu.hw?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/include/apu.hw (original) +++ apr/apr-util/trunk/include/apu.hw Thu Nov 20 20:05:08 2008 @@ -108,14 +108,13 @@ #define APU_HAVE_DB_VERSION 0 #endif -#ifndef APU_DBD_DSO_BUILD #define APU_HAVE_PGSQL 0 #define APU_HAVE_MYSQL 0 #define APU_HAVE_SQLITE3 0 #define APU_HAVE_SQLITE2 0 #define APU_HAVE_ORACLE 0 #define APU_HAVE_FREETDS 0 -#endif + /* Windows always has ODBC */ #define APU_HAVE_ODBC 1 Modified: apr/apr-util/trunk/include/private/apr_dbm_private.h URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/private/apr_dbm_private.h?rev=719467&r1=719466&r2=719467&view=diff ============================================================================== --- apr/apr-util/trunk/include/private/apr_dbm_private.h (original) +++ apr/apr-util/trunk/include/private/apr_dbm_private.h Thu Nov 20 20:05:08 2008 @@ -110,13 +110,11 @@ /* Declare all of the builtin DBM providers */ APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_sdbm; +#ifndef DSO_BUILD APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_gdbm; APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_ndbm; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db1; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db2; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db3; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db4; APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db; +#endif #ifdef __cplusplus }