summaryrefslogtreecommitdiff
path: root/util-misc
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2018-06-14 16:34:49 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2018-06-14 16:34:49 +0000
commitcb99d60bf06a33711e4ff50cf89565b3eda99388 (patch)
tree493b42b956ef6cd883b76f025af13c10438b1232 /util-misc
parent5776cd388d14a27f7ac4f4484bf6d006b30ca2cf (diff)
downloadlibapr-cb99d60bf06a33711e4ff50cf89565b3eda99388.tar.gz
apr_crypto: follow up to r1833359: fix some root pool scopes (possible leaks).
Keep the root pool scope for things that need it only (global lists of drivers or libs), but otherwise use the passed in pool (crypto libs, default PRNG, errors). This allows the caller to control the scope of initialization functions, and for instance be able to re-initialize when apr_crypto is unloaded/reloaded from a DSO attached to the passed-in pool (e.g. mod_ssl in httpd). apu_dso_load() needs to return its handles when called multiple times (EINIT), it's not the caller's job (like crypto drivers) to maintain them. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1833525 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util-misc')
-rw-r--r--util-misc/apu_dso.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/util-misc/apu_dso.c b/util-misc/apu_dso.c
index dd29076eb..83ab33eca 100644
--- a/util-misc/apu_dso.c
+++ b/util-misc/apu_dso.c
@@ -106,6 +106,11 @@ apr_status_t apu_dso_init(apr_pool_t *pool)
return ret;
}
+struct dso_entry {
+ apr_dso_handle_t *handle;
+ apr_dso_handle_sym_t *sym;
+};
+
apr_status_t apu_dso_load(apr_dso_handle_t **dlhandleptr,
apr_dso_handle_sym_t *dsoptr,
const char *module,
@@ -118,11 +123,14 @@ apr_status_t apu_dso_load(apr_dso_handle_t **dlhandleptr,
apr_array_header_t *paths;
apr_pool_t *global;
apr_status_t rv = APR_EDSOOPEN;
+ struct dso_entry *entry;
char *eos = NULL;
int i;
- *dsoptr = apr_hash_get(dsos, module, APR_HASH_KEY_STRING);
- if (*dsoptr) {
+ entry = apr_hash_get(dsos, module, APR_HASH_KEY_STRING);
+ if (entry) {
+ *dlhandleptr = entry->handle;
+ *dsoptr = entry->sym;
return APR_EINIT;
}
@@ -199,7 +207,10 @@ apr_status_t apu_dso_load(apr_dso_handle_t **dlhandleptr,
}
else {
module = apr_pstrdup(global, module);
- apr_hash_set(dsos, module, APR_HASH_KEY_STRING, *dsoptr);
+ entry = apr_palloc(global, sizeof(*entry));
+ entry->handle = dlhandle;
+ entry->sym = *dsoptr;
+ apr_hash_set(dsos, module, APR_HASH_KEY_STRING, entry);
}
return rv;
}