[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Timeout doesn't work (ITS#983)



> The ldapsearch(1) tools only support LDAP search timelimits
> not API timeouts.

If you'd like to add that support, here's a start. The select() calls
during a bind still can't be given timeouts, since that would require an
API change. But this at least takes care of searches. (i.e. my problem)

diff -u -r1.99 ldapsearch.c
--- clients/tools/ldapsearch.c  2001/01/19 03:55:38     1.99
+++ clients/tools/ldapsearch.c  2001/01/23 20:12:12
@@ -16,6 +16,7 @@
 #include <ac/unistd.h>
 #include <ac/errno.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
@@ -170,10 +171,12 @@
        int                     referrals, timelimit, sizelimit, debug;
        int             authmethod, version, want_bindpw;
        LDAP            *ld = NULL;
+       struct timeval tv;
 
        infile = NULL;
-       debug = verbose = not = vals2tmp = referrals =
-               attrsonly = manageDSAit = ldif = want_bindpw = 0;
+       debug = verbose = not = vals2tmp = referrals = 
+               attrsonly = manageDSAit = ldif = want_bindpw = 
+               tv.tv_sec = tv.tv_usec = 0;
 
        lutil_log_initialize(argc, argv);
 
@@ -222,6 +225,7 @@
                break;
        case 'l':       /* time limit */
                timelimit = atoi( optarg );
+                tv.tv_sec = timelimit;
                break;
        case 'L':       /* print entries in LDIF format */
                ++ldif;
@@ -853,7 +857,7 @@
 
        if ( infile == NULL ) {
                rc = dosearch( ld, base, scope, NULL, filtpattern,
-                       attrs, attrsonly, NULL, NULL, NULL, -1 );
+                       attrs, attrsonly, NULL, NULL, &tv, -1 );
 
        } else {
                rc = 0;
@@ -866,7 +870,7 @@
                                first = 0;
                        }
                        rc = dosearch( ld, base, scope, filtpattern, line,
-                               attrs, attrsonly, NULL, NULL, NULL, -1 );
+                               attrs, attrsonly, NULL, NULL, &tv, -1 );
                }
                if ( fp != stdin ) {
                        fclose( fp );
@@ -935,7 +939,7 @@
 
        while ((rc = ldap_result( ld, LDAP_RES_ANY,
                sortattr ? LDAP_MSG_ALL : LDAP_MSG_ONE,
-               NULL, &res )) > 0 )
+                timelimit, &res )) > 0 )
        {
                if( sortattr ) {
                        (void) ldap_sort_entries( ld, &res,