--- libraries/libldap/result.c 2004/11/28 21:17:52 1.99 +++ libraries/libldap/result.c 2005/06/03 19:12:01 1.99.2.3 @@ -1,8 +1,8 @@ /* result.c - wait for an ldap result */ -/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.98 2004/10/18 02:58:36 jongchoi Exp $ */ +/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.99.2.2 2005/05/06 16:10:22 kurt Exp $ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2005 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -178,6 +178,7 @@ chkResponseList( } if ( lm->lm_chain == NULL ) { + assert(lm->lm_chain_tail == lm); if ((lm->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || (lm->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) || (lm->lm_msgtype == LDAP_RES_INTERMEDIATE)) { @@ -186,6 +187,8 @@ chkResponseList( tmp = lm; } } else { + assert(lm->lm_chain_tail); + assert(lm->lm_chain_tail->lm_chain); if ((lm->lm_chain_tail->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || (lm->lm_chain_tail->lm_chain->lm_msgtype @@ -217,8 +220,11 @@ chkResponseList( ? lm->lm_chain : lm->lm_next); } if ( all == LDAP_MSG_ONE && lm->lm_chain != NULL ) { - lm->lm_chain->lm_next = lm->lm_next; - lm->lm_chain = NULL; + lm->lm_chain->lm_next = lm->lm_next; + lm->lm_chain->lm_chain_tail = ( lm->lm_chain_tail != lm ) ? lm->lm_chain_tail : lm->lm_chain; + assert(lm->lm_chain->lm_chain_tail); + lm->lm_chain = NULL; + lm->lm_chain_tail = NULL; } lm->lm_next = NULL; } @@ -282,9 +288,10 @@ wait4msg( } #endif /* LDAP_DEBUG */ - if( (*result = chkResponseList(ld, msgid, all)) != NULL ) { - rc = (*result)->lm_msgtype; - } else { + if ( (*result = chkResponseList(ld, msgid, all)) != NULL ) { + rc = (*result)->lm_msgtype; + + } else { int lc_ready = 0; for ( lc = ld->ld_conns; lc != NULL; lc = nextlc ) { @@ -294,11 +301,11 @@ wait4msg( rc = try_read1msg( ld, msgid, all, lc->lconn_sb, &lc, result ); lc_ready = 1; - break; + break; } - } + } - if ( !lc_ready ) { + if ( !lc_ready ) { rc = ldap_int_select( ld, tvp ); #ifdef LDAP_DEBUG if ( rc == -1 ) { @@ -852,17 +859,11 @@ lr->lr_res_matched ? lr->lr_res_matched /* part of a search response - add to end of list of entries */ if (l->lm_chain == NULL) { - if ((l->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || - (l->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) || - (l->lm_msgtype == LDAP_RES_INTERMEDIATE)) { - /* do not advance lm_chain_tail in this case */ - l->lm_chain = new; - } else { - /*FIXME: ldap_msgfree( l );*/ - l = new; - l->lm_chain_tail = new; - } + assert(l->lm_chain_tail == l); + l->lm_chain = new; } else { + assert(l->lm_chain_tail); + assert(l->lm_chain_tail->lm_chain); if ((l->lm_chain_tail->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || (l->lm_chain_tail->lm_chain->lm_msgtype