Skip to content

Commit 56337c3

Browse files
committed
apr_ldap: Make sure APR_EINIT returned when the DSO is already loaded
does not get returned as an error. Make sure DSO errors are passed accurately to the caller. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1924466 13f79535-47bb-0310-9956-ffa450edef68
1 parent f05a3bc commit 56337c3

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ldap/apr_ldap_stub.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ static apr_status_t load_ldap(apr_pool_t *pool, const apr_ldap_driver_t **driver
8080
modname = "apr_ldap-" APR_STRINGIFY(APR_MAJOR_VERSION) ".so";
8181
#endif
8282
rv = apu_dso_load(&dlhandle, &symbol, modname, "apr__ldap_fns", pool, err);
83-
if (rv == APR_SUCCESS) {
83+
if (rv == APR_SUCCESS || APR_EINIT == rv) {
8484
lfn = symbol;
85+
rv = APR_SUCCESS;
8586
}
8687

8788
if (driver) {
@@ -93,9 +94,12 @@ static apr_status_t load_ldap(apr_pool_t *pool, const apr_ldap_driver_t **driver
9394
return rv;
9495
}
9596

96-
#define LOAD_LDAP_STUB(pool, err, failres) \
97-
if (!lfn && (apr_ldap_get_driver(pool, NULL, err) != APR_SUCCESS)) \
98-
return failres;
97+
#define LOAD_LDAP_STUB(pool, err) \
98+
{ \
99+
apr_status_t status; \
100+
if (!lfn && ((status = apr_ldap_get_driver(pool, NULL, err)) != APR_SUCCESS)) \
101+
return status; \
102+
}
99103

100104
#define CHECK_LDAP_STUB(failres) \
101105
if (!lfn) \
@@ -132,15 +136,15 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_info(apr_pool_t *pool,
132136
apu_err_t **result_err)
133137
{
134138
*result_err = (apu_err_t *)apr_pcalloc(pool, sizeof(apu_err_t));
135-
LOAD_LDAP_STUB(pool, *result_err, APR_EINIT);
139+
LOAD_LDAP_STUB(pool, *result_err);
136140
return lfn->info(pool, result_err);
137141
}
138142

139143
APU_DECLARE_LDAP(apr_status_t) apr_ldap_initialise(apr_pool_t *pool,
140144
apr_ldap_t **ldap,
141145
apu_err_t *err)
142146
{
143-
LOAD_LDAP_STUB(pool, err, APR_EINIT);
147+
LOAD_LDAP_STUB(pool, err);
144148
return lfn->initialise(pool, ldap, err);
145149
}
146150

@@ -150,7 +154,7 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_option_get(apr_pool_t *pool,
150154
apr_ldap_opt_t *outvalue,
151155
apu_err_t *err)
152156
{
153-
LOAD_LDAP_STUB(pool, err, APR_EINIT);
157+
LOAD_LDAP_STUB(pool, err);
154158
return lfn->option_get(pool, ldap, option, outvalue, err);
155159
}
156160

@@ -160,7 +164,7 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_option_set(apr_pool_t *pool,
160164
const apr_ldap_opt_t *invalue,
161165
apu_err_t *err)
162166
{
163-
LOAD_LDAP_STUB(pool, err, APR_EINIT);
167+
LOAD_LDAP_STUB(pool, err);
164168
return lfn->option_set(pool, ldap, option, invalue, err);
165169
}
166170

0 commit comments

Comments
 (0)