]> git.sur5r.net Git - openldap/commitdiff
add network timeout (ITS#2413 reworked)
authorPierangelo Masarati <ando@openldap.org>
Sat, 3 May 2003 11:30:38 +0000 (11:30 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 3 May 2003 11:30:38 +0000 (11:30 +0000)
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/config.c
servers/slapd/back-meta/conn.c

index 463fc5a7c138b55f4cc5fab58ecb9e4124a4e2ff..41b6cda62804505b96a91dbcd307393a2b8eaf40 100644 (file)
@@ -146,6 +146,7 @@ struct metadncache {
 struct metainfo {
        int                     ntargets;
        int                     defaulttarget;
+       int                     network_timeout;
 #define META_DEFAULT_TARGET_NONE       -1
        struct metatarget       **targets;
 
index 6c0f88a92eb748dba512ad28a9b11995156c79f6..664cbd5199d1a5a8a482b9e56d34e45e3305f7c0 100644 (file)
@@ -312,6 +312,16 @@ meta_back_db_config(
                        li->cache.ttl = atol( argv[ 1 ] );
                }
 
+       /* network timeout when connecting to ldap servers */
+       } else if ( strcasecmp( argv[ 0 ], "network-timeout" ) == 0 ) {
+               if ( argc != 2 ) {
+                       fprintf( stderr,
+       "%s: line %d: missing network timeout in \"network-timeout <seconds>\" line\n",
+                               fname, lineno );
+                       return 1;
+               }
+               li->network_timeout = atol(argv[ 1 ]);
+
        /* name to use for meta_back_group */
        } else if ( strcasecmp( argv[ 0 ], "binddn" ) == 0 ) {
                int             i = li->ntargets-1;
index b2f9f0969b8a8526ff5ea78a711cb97002b8446a..84f970d3cd69371978b9b3cbde6a9339de759a9f 100644 (file)
@@ -235,6 +235,7 @@ init_one_conn(
                struct metasingleconn   *lsc
                )
 {
+       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
        int             vers;
        dncookie        dc;
 
@@ -262,6 +263,18 @@ init_one_conn(
        /* FIXME: configurable? */
        ldap_set_option(lsc->ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON);
 
+       /*
+        * Set the network timeout if set
+        */
+       if (li->network_timeout != 0){
+               struct timeval network_timeout;
+
+               network_timeout.tv_usec = 0;
+               network_timeout.tv_sec = li->network_timeout;
+
+               ldap_set_option( lsc->ld, LDAP_OPT_NETWORK_TIMEOUT, (void *) &network_timeout);
+       }
+
        /*
         * Sets a cookie for the rewrite session
         */