Author: jra
Date: 2005-01-11 02:13:09 +0000 (Tue, 11 Jan 2005)
New Revision: 4666

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4666

Log:
Fix inspired by posting from Joe Meadows <[EMAIL PROTECTED]>.
Make all LDAP timeouts consistent.
Jeremy.

Modified:
   trunk/source/include/ads.h
   trunk/source/libads/ldap.c


Changeset:
Modified: trunk/source/include/ads.h
===================================================================
--- trunk/source/include/ads.h  2005-01-11 02:13:03 UTC (rev 4665)
+++ trunk/source/include/ads.h  2005-01-11 02:13:09 UTC (rev 4666)
@@ -76,9 +76,6 @@
 /* time between reconnect attempts */
 #define ADS_RECONNECT_TIME 5
 
-/* timeout on searches */
-#define ADS_SEARCH_TIMEOUT 10
-
 /* ldap control oids */
 #define ADS_PAGE_CTL_OID "1.2.840.113556.1.4.319"
 #define ADS_NO_REFERRALS_OID "1.2.840.113556.1.4.1339"

Modified: trunk/source/libads/ldap.c
===================================================================
--- trunk/source/libads/ldap.c  2005-01-11 02:13:03 UTC (rev 4665)
+++ trunk/source/libads/ldap.c  2005-01-11 02:13:09 UTC (rev 4666)
@@ -75,20 +75,24 @@
                                    int attrsonly,
                                    LDAPControl **sctrls,
                                    LDAPControl **cctrls,
-                                   struct timeval *timeout,
                                    int sizelimit,
                                    LDAPMessage **res )
 {
+       struct timeval timeout;
        int result;
 
-       /* Setup timeout */
+       /* Setup timeout for the ldap_search_ext_s call - local and remote. */
+       timeout.tv_sec = lp_ldap_timeout();
+       timeout.tv_usec = 0;
+
+       /* Setup alarm timeout.... Do we need both of these ? JRA. */
        gotalarm = 0;
        CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
        alarm(lp_ldap_timeout());
        /* End setup timeout. */
 
        result = ldap_search_ext_s(ld, base, scope, filter, attrs,
-                                  attrsonly, sctrls, cctrls, timeout,
+                                  attrsonly, sctrls, cctrls, &timeout,
                                   sizelimit, res);
 
        /* Teardown timeout. */
@@ -504,14 +508,14 @@
 
        rc = ldap_search_with_timeout(ads->ld, utf8_path, scope, utf8_expr, 
                                      search_attrs, 0, controls,
-                                     NULL, NULL, LDAP_NO_LIMIT,
+                                     NULL, LDAP_NO_LIMIT,
                                      (LDAPMessage **)res);
 
        ber_free(cookie_be, 1);
        ber_bvfree(cookie_bv);
 
        if (rc) {
-               DEBUG(3,("ldap_search_with_timeout(%s) -> %s\n", expr,
+               DEBUG(3,("ads_do_paged_search: ldap_search_with_timeout(%s) -> 
%s\n", expr,
                         ldap_err2string(rc)));
                goto done;
        }
@@ -655,7 +659,6 @@
                         const char *expr,
                         const char **attrs, void **res)
 {
-       struct timeval timeout;
        int rc;
        char *utf8_expr, *utf8_path, **search_attrs = NULL;
        TALLOC_CTX *ctx;
@@ -689,15 +692,12 @@
                }
        }
 
-       timeout.tv_sec = ADS_SEARCH_TIMEOUT;
-       timeout.tv_usec = 0;
-
        /* see the note in ads_do_paged_search - we *must* disable referrals */
        ldap_set_option(ads->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
 
        rc = ldap_search_with_timeout(ads->ld, utf8_path, scope, utf8_expr,
                                      search_attrs, 0, NULL, NULL, 
-                                     &timeout, LDAP_NO_LIMIT,
+                                     LDAP_NO_LIMIT,
                                      (LDAPMessage **)res);
 
        if (rc == LDAP_SIZELIMIT_EXCEEDED) {

Reply via email to