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

libldap/result.c changes for ITS #2982, not quite right (ITS#3250)



Full_Name: Arlene Berry
Version: 2.2.13, 2.1.29, 2.1.30
OS: RedHat 9
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (64.221.115.99)


I'm trying to use PADL's nss_ldap on RedHat 9 and Windows 2003 Active Directory
with SFU 3.5 for the LDAP server.  The problem is that when chasing referrals,
which nss_ldap does, things hang for five minutes.  I reproduced the problem
with ldapsearch using the -C option.  I tracked the problem down to the the
changes made to libldap/result.c between versions 2.1.28 and 2.1.29 of OpenLDAP
(ITS #2982).  The problem is this code around line 305:

                   for ( lc = ld->ld_conns; lc != NULL; lc = nextlc ) {
                           nextlc = lc->lconn_next;
                           if ( ber_sockbuf_ctrl( lc->lconn_sb,
                                           LBER_SB_OPT_DATA_READY, NULL ) ) {
                                   rc = try_read1msg( ld, msgid, all,
lc->lconn_sb,
                                           &lc, result );
                               break;
                           }
                }

                if ( lc == NULL ) {
                       rc = ldap_int_select( ld, tvp );
                ...

When I turned on debugging I saw newer versions going into ldap_int_select()
which older versions do not.  The reason is that in the newer versions
try_read1msg() may set lc to NULL which it didn't prior to this change.  The
result is it now enters the if statement which it didn't previously.  I restored
the old behavior by doing the following:

                   int lc_found = 0;
                   ...
                   for ( lc = ld->ld_conns; lc != NULL; lc = nextlc ) {
                           nextlc = lc->lconn_next;
                           if ( ber_sockbuf_ctrl( lc->lconn_sb,
                                           LBER_SB_OPT_DATA_READY, NULL ) ) {
                                   rc = try_read1msg( ld, msgid, all,
lc->lconn_sb,
                                           &lc, result );
                               lc_found = 1;
                               break;
                           }
                }

                if ( !lc_found ) {
                       rc = ldap_int_select( ld, tvp );
                ...

This fixed the five minute hang.