]> git.sur5r.net Git - openldap/commitdiff
line up network-timeout with back-meta
authorPierangelo Masarati <ando@openldap.org>
Fri, 7 Apr 2006 09:08:37 +0000 (09:08 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 7 Apr 2006 09:08:37 +0000 (09:08 +0000)
servers/slapd/back-ldap/bind.c
servers/slapd/back-ldap/config.c

index cc497ff04c8b0ed0c06f543981eb85f81a41ce5b..5ce7c02058fa84cf02f74d67d3efdca09d880568 100644 (file)
@@ -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 );
index 38c9a95296473d0a1e571c003b54144226b71ef7..8462ad7746f66745a15badea6730036167d2b33e 100644 (file)
@@ -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]> <real", 2, 3, 0,
                ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
                ldap_back_cf_gen, NULL, NULL, NULL },
@@ -583,6 +592,19 @@ ldap_back_cf_gen( ConfigArgs *c )
                        value_add_one( &c->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 "