apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1212356 - in /apr/apr-util/branches/1.4.x: ./ CHANGES crypto/apr_crypto.c crypto/apr_crypto_nss.c crypto/apr_crypto_openssl.c include/private/apr_crypto_internal.h
Date Fri, 09 Dec 2011 12:17:43 GMT
Author: minfrin
Date: Fri Dec  9 12:17:42 2011
New Revision: 1212356

URL: http://svn.apache.org/viewvc?rev=1212356&view=rev
Log:
Backport:
apr_crypto: Move the static initialisation of DRIVER_LOAD from
apr_crypto_init() to apr_crypto_get_driver(), so that we don't lose
the parameters.

Modified:
    apr/apr-util/branches/1.4.x/   (props changed)
    apr/apr-util/branches/1.4.x/CHANGES
    apr/apr-util/branches/1.4.x/crypto/apr_crypto.c
    apr/apr-util/branches/1.4.x/crypto/apr_crypto_nss.c
    apr/apr-util/branches/1.4.x/crypto/apr_crypto_openssl.c
    apr/apr-util/branches/1.4.x/include/private/apr_crypto_internal.h

Propchange: apr/apr-util/branches/1.4.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec  9 12:17:42 2011
@@ -1,4 +1,4 @@
-/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,1207704,1210524
+/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,1127648-1127649,1187984,1207704,1210524,1211987
 /apr/apr-util/branches/1.3.x:896410,979221-979222,979232,1001059,1002632,1002648,1002733,1003214,1003255,1003358,1003370,1003376,1003602,1005956,1005962,1006017,1006137,1154885
-/apr/apr-util/branches/1.5.x:1002504,1002584-1002585,1002620,1002622-1002623,1002628,1207683,1207690,1207707,1209594,1210530
+/apr/apr-util/branches/1.5.x:1002504,1002584-1002585,1002620,1002622-1002623,1002628,1207683,1207690,1207707,1209594,1210530,1212347
 /apr/apr-util/trunk:731033-731034,731225,731236,731291,731293,731379,743986,744009,745771,747612,747623,747630

Modified: apr/apr-util/branches/1.4.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.4.x/CHANGES?rev=1212356&r1=1212355&r2=1212356&view=diff
==============================================================================
--- apr/apr-util/branches/1.4.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.4.x/CHANGES [utf-8] Fri Dec  9 12:17:42 2011
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR-Util 1.4.2
 
+  *) apr_crypto: Move the static initialisation of DRIVER_LOAD from
+     apr_crypto_init() to apr_crypto_get_driver(), so that we don't lose
+     the parameters. [Graham Leggett]
 
 Changes with APR-Util 1.4.1
 

Modified: apr/apr-util/branches/1.4.x/crypto/apr_crypto.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.4.x/crypto/apr_crypto.c?rev=1212356&r1=1212355&r2=1212356&view=diff
==============================================================================
--- apr/apr-util/branches/1.4.x/crypto/apr_crypto.c (original)
+++ apr/apr-util/branches/1.4.x/crypto/apr_crypto.c Fri Dec  9 12:17:42 2011
@@ -68,12 +68,12 @@ typedef struct apr_crypto_clear_t {
 } apr_crypto_clear_t;
 
 #if !APU_DSO_BUILD
-#define DRIVER_LOAD(name,driver,pool) \
+#define DRIVER_LOAD(name,driver,pool,params,rv,result) \
     {   \
         extern const apr_crypto_driver_t driver; \
         apr_hash_set(drivers,name,APR_HASH_KEY_STRING,&driver); \
         if (driver.init) {     \
-            driver.init(pool, NULL, NULL); \
+            rv = driver.init(pool, params, result); \
         }  \
     }
 #endif
@@ -107,22 +107,6 @@ APU_DECLARE(apr_status_t) apr_crypto_ini
 #endif
     drivers = apr_hash_make(pool);
 
-#if !APU_DSO_BUILD
-    /* Load statically-linked drivers: */
-#if APU_HAVE_OPENSSL
-    DRIVER_LOAD("openssl", apr_crypto_openssl_driver, pool);
-#endif
-#if APU_HAVE_NSS
-    DRIVER_LOAD("nss", apr_crypto_nss_driver, pool);
-#endif
-#if APU_HAVE_MSCAPI
-    DRIVER_LOAD("mscapi", apr_crypto_mscapi_driver, pool);
-#endif
-#if APU_HAVE_MSCNG
-    DRIVER_LOAD("mscng", apr_crypto_mscng_driver, pool);
-#endif
-#endif /* APU_DSO_BUILD */
-
     apr_pool_cleanup_register(pool, NULL, apr_crypto_term,
             apr_pool_cleanup_null);
 
@@ -165,7 +149,10 @@ APU_DECLARE(apr_status_t) apr_crypto_get
     apr_dso_handle_sym_t symbol;
 #endif
     apr_status_t rv;
-    int rc = 0;
+
+    if (result) {
+        *result = NULL; /* until further notice */
+    }
 
 #if APU_DSO_BUILD
     rv = apu_dso_mutex_lock();
@@ -207,27 +194,51 @@ APU_DECLARE(apr_status_t) apr_crypto_get
     }
     *driver = symbol;
     if ((*driver)->init) {
-        rv = (*driver)->init(pool, params, &rc);
+        rv = (*driver)->init(pool, params, result);
+    }
+    if (rv == APR_SUCCESS) {
+        name = apr_pstrdup(pool, name);
+        apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
     }
-    name = apr_pstrdup(pool, name);
-    apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
 
     unlock: apu_dso_mutex_unlock();
 
-    if (APR_SUCCESS != rv && result) {
+    if (APR_SUCCESS != rv && result && !*result) {
         char *buffer = apr_pcalloc(pool, ERROR_SIZE);
         apu_err_t *err = apr_pcalloc(pool, sizeof(apu_err_t));
         if (err && buffer) {
             apr_dso_error(dso, buffer, ERROR_SIZE - 1);
             err->msg = buffer;
             err->reason = modname;
-            err->rc = rc;
             *result = err;
         }
     }
 
 #else /* not builtin and !APR_HAS_DSO => not implemented */
     rv = APR_ENOTIMPL;
+
+    /* Load statically-linked drivers: */
+#if APU_HAVE_OPENSSL
+    if (name[0] == 'o' && !strcmp(name, "openssl")) {
+        DRIVER_LOAD("openssl", apr_crypto_openssl_driver, pool, params, rv, result);
+    }
+#endif
+#if APU_HAVE_NSS
+    else if (name[0] == 'n' && !strcmp(name, "nss")) {
+        DRIVER_LOAD("nss", apr_crypto_nss_driver, pool, params, rv, result);
+    }
+#endif
+#if APU_HAVE_MSCAPI
+    else if (name[0] == 'm' && !strcmp(name, "mscapi")) {
+        DRIVER_LOAD("mscapi", apr_crypto_mscapi_driver, pool, params, rv, result);
+    }
+#endif
+#if APU_HAVE_MSCNG
+    else if (name[0] == 'm' && !strcmp(name, "mscng")) {
+        DRIVER_LOAD("mscng", apr_crypto_mscng_driver, pool, params, rv, result);
+    }
+#endif
+
 #endif
 
     return rv;

Modified: apr/apr-util/branches/1.4.x/crypto/apr_crypto_nss.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.4.x/crypto/apr_crypto_nss.c?rev=1212356&r1=1212355&r2=1212356&view=diff
==============================================================================
--- apr/apr-util/branches/1.4.x/crypto/apr_crypto_nss.c (original)
+++ apr/apr-util/branches/1.4.x/crypto/apr_crypto_nss.c Fri Dec  9 12:17:42 2011
@@ -121,7 +121,8 @@ static apr_status_t crypto_shutdown_help
 /**
  * Initialise the crypto library and perform one time initialisation.
  */
-static apr_status_t crypto_init(apr_pool_t *pool, const char *params, int *rc)
+static apr_status_t crypto_init(apr_pool_t *pool, const char *params,
+        const apu_err_t **result)
 {
     SECStatus s;
     const char *dir = NULL;
@@ -209,8 +210,12 @@ static apr_status_t crypto_init(apr_pool
         s = NSS_NoDB_Init(NULL);
     }
     if (s != SECSuccess) {
-        if (rc) {
-            *rc = PR_GetError();
+        if (result) {
+            apu_err_t *err = apr_pcalloc(pool, sizeof(apu_err_t));
+            err->rc = PR_GetError();
+            err->msg = PR_ErrorToName(s);
+            err->reason = "Error during 'nss' initialisation";
+            *result = err;
         }
         return APR_ECRYPT;
     }

Modified: apr/apr-util/branches/1.4.x/crypto/apr_crypto_openssl.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.4.x/crypto/apr_crypto_openssl.c?rev=1212356&r1=1212355&r2=1212356&view=diff
==============================================================================
--- apr/apr-util/branches/1.4.x/crypto/apr_crypto_openssl.c (original)
+++ apr/apr-util/branches/1.4.x/crypto/apr_crypto_openssl.c Fri Dec  9 12:17:42 2011
@@ -108,7 +108,8 @@ static apr_status_t crypto_shutdown_help
 /**
  * Initialise the crypto library and perform one time initialisation.
  */
-static apr_status_t crypto_init(apr_pool_t *pool, const char *params, int *rc)
+static apr_status_t crypto_init(apr_pool_t *pool, const char *params,
+        const apu_err_t **result)
 {
     CRYPTO_malloc_init();
     ERR_load_crypto_strings();

Modified: apr/apr-util/branches/1.4.x/include/private/apr_crypto_internal.h
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.4.x/include/private/apr_crypto_internal.h?rev=1212356&r1=1212355&r2=1212356&view=diff
==============================================================================
--- apr/apr-util/branches/1.4.x/include/private/apr_crypto_internal.h (original)
+++ apr/apr-util/branches/1.4.x/include/private/apr_crypto_internal.h Fri Dec  9 12:17:42
2011
@@ -39,7 +39,8 @@ struct apr_crypto_driver_t {
      * @param params Optional init parameter string.
      * @param rc Driver-specific additional error code
      */
-    apr_status_t (*init)(apr_pool_t *pool, const char *params, int *rc);
+    apr_status_t (*init)(apr_pool_t *pool, const char *params,
+            const apu_err_t **result);
 
     /**
      * @brief Create a context for supporting encryption. Keys, certificates,



Mime
View raw message