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

Setting timeouts in OpenLDAP



2.3.36 on FreeBSD 6.2-STABLE.

We have a need for the client to detect a hung server, so I thought I'd 
try something like this, called before each new connection:

    struct timeval  tv;

    tv.tv_sec = 5;
    tv.tv_usec = 0;
    ldap_set_option(ld, LDAP_OPT_TIMEOUT, &tv);
    ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &tv);

(In the actual code I do test for errors.)

I then ran "nc -l 389" to simulate a hung server, and issued a search 
against it, but it never times out.  Attaching to the client with GDB and 
getting a back-trace shows this:

(gdb) bt
#0  0x28180873 in poll () from /lib/libc.so.6
#1  0x280dfca9 in ldap_int_select () from /usr/local/lib/libldap-2.3.so.2
#2  0x280d00d0 in ldap_result () from /usr/local/lib/libldap-2.3.so.2
#3  0x280d155b in ldap_search_s () from /usr/local/lib/libldap-2.3.so.2
#4  0x08049d50 in getporthost (app=0xbfbfe944 "fgh", portnum=0xbfbfe7d8, 
    host=0x804b520 "") at getporthost.c:200
#5  0x08048e8c in main (c=1, v=0xbfbfe840) at main.c:50

Do timeouts actually work?  If so, what have I misunderstood?

-- 
Dave Horsfall DTM VK2KFU  Ph: +61 2 9552-5509 (direct) +61 2 9552-5500 (switch)
Corinthian Eng'ng P/L, Ste 54 Jones Bay Whf, 26-32 Pirrama Rd, Pyrmont 2009, AU