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

ldap_search blocks after several hundred consequtive searches without ldap_result being called (ITS#2389)

Full_Name: Rand Wacker
Version: 2.0.27
OS: Linux/Solaris 8
URL: ftp://ftp.openldap.org/incoming/rand-at-sendmail-dot-com-blocker.c
Submission from: (NULL) (

We have a component that under certain conditions will send several hundred
ldap_search() requests to an LDAP server without calling ldap_result() in
between them.  I am observing that under these conditions, ldap_search() will
eventually block in a write call at sb_stream_write() (sockbuf.c:539).  The
searches are all very small, with a filter of simply
(mailRoutingAddress=foo@domain.com) and requesting only one attribute.

I've written a test program to just send off a bunch of search requests without
calling ldap_result and it exhibits this same behaviour.  I've uploaded the test
program to the FTP incoming directory.  The stack trace from GDB when it locks
up looks like this on Linux:

#0  0x40149404 in write () from /lib/libc.so.6
#1  0x40030ae0 in __DTOR_END__ () from /lib/libpthread.so.0
#2  0x08056db3 in sb_stream_write (sbiod=0x805d798, buf=0x82544c0, len=110)
    at sockbuf.c:539
#3  0x080570c2 in sb_rdahead_write (sbiod=0x805d7b0, buf=0x82544c0, len=110)
    at sockbuf.c:670
#4  0x0805749f in sb_debug_write (sbiod=0x80617e8, buf=0x82544c0, len=110)
    at sockbuf.c:833
#5  0x08056cd4 in ber_int_sb_write (sb=0x805c6b8, buf=0x82544c0, len=110)
    at sockbuf.c:423
#6  0x080550d0 in ber_flush (sb=0x805c6b8, ber=0x8254490, freeit=0) at io.c:229
#7  0x0804b2f7 in ldap_send_server_request (ld=0x805c5a0, ber=0x8254490, 
    msgid=1813, parentreq=0x0, srvlist=0x0, lc=0x0, bind=0x0) at request.c:202
#8  0x0804b14f in ldap_send_initial_request (ld=0x805c5a0, msgtype=99, 
    dn=0xbffffb98 "dc=sendmail,dc=com", ber=0x8254490) at request.c:110
#9  0x08049820 in ldap_search (ld=0x805c5a0, 
    base=0xbffffb98 "dc=sendmail,dc=com", scope=2, 
    filter=0x8057640 "(mailRoutingAddress=rand@sendmail.com)", 
    attrs=0xbffff99c, attrsonly=0) at search.c:240
#10 0x08049205 in main (argc=5, argv=0xbffffa34) at blocker.c:68

I am using the OpenLDAP 2.0.27 client libraries.  This stack trace is from a
Debian Linux machine (glibc 2.2.5, kernel 2.4.18), and I see the same behaviour
on Solaris 8.

I was under the impression that ldap_search() should never block.  But I will
have to admit that sending several hundred search requests in a row without
calling ldap_result() is a little, well, out of the ordinary.

Thanks - Rand