From: Bradley Nicholes Date: Tue, 26 Apr 2005 23:52:41 +0000 (+0000) Subject: Move the ldap_set_option() call to set the connection time from being global to being... X-Git-Tag: 2.1.5~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f05f8523c443f1695c2cb602a96b910c631ef69c;p=thirdparty%2Fapache%2Fhttpd.git Move the ldap_set_option() call to set the connection time from being global to being connection specific. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@164919 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/ldap/util_ldap.c b/modules/ldap/util_ldap.c index 8a680c11958..4d252bb1d7d 100644 --- a/modules/ldap/util_ldap.c +++ b/modules/ldap/util_ldap.c @@ -247,6 +247,10 @@ static int uldap_connection_open(request_rec *r, int failures = 0; int version = LDAP_VERSION3; apr_ldap_err_t *result = NULL; + struct timeval timeOut = {10,0}; /* 10 second connection timeout */ + util_ldap_state_t *st = + (util_ldap_state_t *)ap_get_module_config(r->server->module_config, + &ldap_module); /* sanity check for NULL */ if (!ldc) { @@ -326,6 +330,22 @@ static int uldap_connection_open(request_rec *r, /* always default to LDAP V3 */ ldap_set_option(ldc->ldap, LDAP_OPT_PROTOCOL_VERSION, &version); +#ifdef LDAP_OPT_NETWORK_TIMEOUT + if (st->connectionTimeout > 0) { + timeOut.tv_sec = st->connectionTimeout; + } + + if (st->connectionTimeout >= 0) { + rc = apr_ldap_set_option(ldc->pool, ldc->ldap, LDAP_OPT_NETWORK_TIMEOUT, + (void *)&timeOut, &(result)); + if (APR_SUCCESS != rc) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "LDAP: Could not set the connection timeout"); + } + } +#endif + + } @@ -1773,7 +1793,6 @@ static int util_ldap_post_config(apr_pool_t *p, apr_pool_t *plog, const char *userdata_key = "util_ldap_init"; apr_ldap_err_t *result_err = NULL; int rc; - struct timeval timeOut = {10,0}; /* 10 second connection timeout */ /* util_ldap_post_config() will be called twice. Don't bother * going through all of the initialization on the first call @@ -1907,22 +1926,6 @@ static int util_ldap_post_config(apr_pool_t *p, apr_pool_t *plog, "LDAP: SSL support unavailable" ); } -#ifdef LDAP_OPT_NETWORK_TIMEOUT - if (st->connectionTimeout > 0) { - timeOut.tv_sec = st->connectionTimeout; - } - - if (st->connectionTimeout >= 0) { - rc = apr_ldap_set_option(p, NULL, LDAP_OPT_NETWORK_TIMEOUT, - (void *)&timeOut, &(result_err)); - if (APR_SUCCESS != rc) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, - "LDAP: Could not set the connection timeout"); - } - } -#endif - - return(OK); }