From 6a293c65b32a8e2e3101e4776cd36828cd54285d Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 7 Apr 2006 09:08:37 +0000 Subject: [PATCH] line up network-timeout with back-meta --- servers/slapd/back-ldap/bind.c | 8 +++++++ servers/slapd/back-ldap/config.c | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index cc497ff04c..5ce7c02058 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -485,6 +485,14 @@ ldap_back_prepare_conn( ldapconn_t **lcp, Operation *op, SlapReply *rs, ldap_bac ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_BACK_CHASE_REFERRALS( li ) ? LDAP_OPT_ON : LDAP_OPT_OFF ); + if ( li->li_network_timeout > 0 ) { + struct timeval tv; + + tv.tv_sec = li->li_network_timeout; + tv.tv_usec = 0; + ldap_set_option( ld, LDAP_OPT_NETWORK_TIMEOUT, (const void *)&tv ); + } + #ifdef HAVE_TLS rs->sr_err = ldap_back_start_tls( ld, op->o_protocol, &is_tls, li->li_uri, li->li_flags, li->li_nretries, &rs->sr_text ); diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index 38c9a95296..8462ad7746 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -62,6 +62,7 @@ enum { LDAP_BACK_CFG_TIMEOUT, LDAP_BACK_CFG_IDLE_TIMEOUT, LDAP_BACK_CFG_CONN_TTL, + LDAP_BACK_CFG_NETWORK_TIMEOUT, LDAP_BACK_CFG_REWRITE, LDAP_BACK_CFG_LAST @@ -232,6 +233,14 @@ static ConfigTable ldapcfg[] = { "SYNTAX OMsDirectoryString " "SINGLE-VALUE )", NULL, NULL }, + { "network-timeout", "timeout", 2, 0, 0, + ARG_MAGIC|LDAP_BACK_CFG_NETWORK_TIMEOUT, + ldap_back_cf_gen, "( OLcfgDbAt:3.17 " + "NAME 'olcDbNetworkTimeout' " + "DESC 'connection network timeout' " + "SYNTAX OMsDirectoryString " + "SINGLE-VALUE )", + NULL, NULL }, { "suffixmassage", "[virtual]> rvalue_vals, &bv ); } break; + case LDAP_BACK_CFG_NETWORK_TIMEOUT: { + char buf[ SLAP_TEXT_BUFLEN ]; + + if ( li->li_network_timeout == 0 ) { + return 1; + } + + snprintf( buf, sizeof( buf ), "%ld", + (long)li->li_network_timeout ); + ber_str2bv( buf, 0, 0, &bv ); + value_add_one( &c->rvalue_vals, &bv ); + } break; + default: /* FIXME: we need to handle all... */ assert( 0 ); @@ -668,6 +690,10 @@ ldap_back_cf_gen( ConfigArgs *c ) li->li_conn_ttl = 0; break; + case LDAP_BACK_CFG_NETWORK_TIMEOUT: + li->li_network_timeout; + break; + default: /* FIXME: we need to handle all... */ assert( 0 ); @@ -1205,6 +1231,19 @@ done_url:; li->li_conn_ttl = (time_t)t; } break; + case LDAP_BACK_CFG_NETWORK_TIMEOUT: { + unsigned long t; + + if ( lutil_parse_time( c->argv[ 1 ], &t ) != 0 ) { + snprintf( c->msg, sizeof( c->msg), + "unable to parse network timeout \"%s\"", + c->argv[ 1 ] ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); + return 1; + } + li->li_network_timeout = (time_t)t; + } break; + case LDAP_BACK_CFG_REWRITE: snprintf( c->msg, sizeof( c->msg ), "rewrite/remap capabilities have been moved " -- 2.39.5