Dave Horsfall wrote:
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?
The network timeout only controls how long to wait for a connection to be opened. The OPT_TIMEOUT option does nothing at all in OpenLDAP 2.3 and older; it appears to have been introduced early on with ever being implemented. It actually works in OpenLDAP 2.4.