From: Howard Chu Date: Mon, 5 Feb 2007 11:03:59 +0000 (+0000) Subject: Add timeout / network timeout to bindconf X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~78 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b5d83415694d5f838746408524ae0061f6b28703;p=openldap Add timeout / network timeout to bindconf --- diff --git a/servers/slapd/config.c b/servers/slapd/config.c index e69a32c4ab..15c5111e9c 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -1033,6 +1033,8 @@ static slap_cf_aux_table bindkey[] = { { BER_BVC("uri="), offsetof(slap_bindconf, sb_uri), 'b', 1, NULL }, { BER_BVC("version="), offsetof(slap_bindconf, sb_version), 'i', 0, versionkey }, { BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'i', 0, methkey }, + { BER_BVC("timeout="), offsetof(slap_bindconf, sb_timeout_api), 'i', 0, NULL }, + { BER_BVC("network-timeout="), offsetof(slap_bindconf, sb_timeout_net), 'i', 0, NULL }, { BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, (slap_verbmasks *)dnNormalize }, { BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 'b', 1, NULL }, { BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 'b', 0, NULL }, @@ -1503,6 +1505,7 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb ) { LDAP *ld = NULL; int rc; + struct timeval tv; /* Init connection to master */ rc = ldap_initialize( &ld, sb->sb_uri.bv_val ); @@ -1519,6 +1522,18 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb ) (const void *)&sb->sb_version ); } + if ( sb->sb_timeout_api ) { + tv.tv_sec = sb->sb_timeout_api; + tv.tv_usec = 0; + ldap_set_option( ld, LDAP_OPT_TIMEOUT, &tv ); + } + + if ( sb->sb_timeout_net ) { + tv.tv_sec = sb->sb_timeout_net; + tv.tv_usec = 0; + ldap_set_option( ld, LDAP_OPT_NETWORK_TIMEOUT, &tv ); + } + #ifdef HAVE_TLS if ( sb->sb_tls_do_init ) { rc = bindconf_tls_set( sb, ld ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 720046d25c..0495eb0047 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1538,6 +1538,8 @@ typedef struct slap_bindconf { int sb_version; int sb_tls; int sb_method; + int sb_timeout_api; + int sb_timeout_net; struct berval sb_binddn; struct berval sb_cred; struct berval sb_saslmech;