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

ldap_search_s(t) and time-outs

I'm using OpenLDAP version 2.1.2 and am having troubles enforcing a
time-out on a search operation. I wanted to clarify whether I was
missing some obvious step, whether some steps on the LDAP server side
are required, or whether its a known issue that has been resolved
or is yet in the process of being resolved.

Before I perform initial bind (using ldap_sasl_bind and SSL context),
I set LDAP_OPT_NETWORK_TIMEOUT to 5 seconds... this seems to work a
treat on the bind time-out. The problem occurs after I unplug the
network cable on the LDAP server machine and try to perform a
search using the LDAP session handle I obtained earlier.

char* attrs[] = {LDAP_NO_ATTRS, NULL};
LDAPMessage* res = NULL;
ldapRc = ldap_search_st(ld, baseDnUtf8.c_str(), scope,
filterUtf8.c_str(), attrs, FALSE, NULL, &res);

The ldap_search_st function call doesn't seem to return for at least
40-120 seconds. Before making this post I've tried everything I can
think of, including 1) setting LDAP_OPT_TIMELIMIT to 5 seconds... this
is supposedly setting the server-side limit, 2) initializing timeval
struct, setting tv_sec member to 5 and passing in an address of the
struct as the second-last parameter to ldap_search_st... this is
supposedly setting the client-side time-out, 3) calling ldap_search_s,
4) using Simple (username/password) authentication, instead of SSL. I
guess next thing on my TO-TRY list is doing a debug build of all
components and trying to track down in which OpenLDAP function the
wait occurs. I noticed (by looking in CVSWeb) that there was some fix
to wait4msg routine made post-version-2.1.2, wonder if that has any
bearing on my scenario.

any tips/suggestions/enlightenments would be appreciated