version 1.99.2.8, 2005/09/28 00:30:28
|
version 1.99.2.9, 2005/10/10 17:35:26
|
Line 1
|
Line 1
|
/* result.c - wait for an ldap result */ |
/* result.c - wait for an ldap result */ |
/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.114 2005/09/10 17:00:15 ando Exp $ */ |
/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.115 2005/10/08 16:51:15 hyc Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 1998-2005 The OpenLDAP Foundation. |
* Copyright 1998-2005 The OpenLDAP Foundation. |
Line 137 chkResponseList(
|
Line 137 chkResponseList(
|
int msgid, |
int msgid, |
int all) |
int all) |
{ |
{ |
LDAPMessage *lm, *lastlm, *nextlm; |
LDAPMessage *lm, **lastlm, *nextlm; |
/* |
/* |
* Look through the list of responses we have received on |
* Look through the list of responses we have received on |
* this association and see if the response we're interested in |
* this association and see if the response we're interested in |
Line 148 chkResponseList(
|
Line 148 chkResponseList(
|
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"ldap_chkResponseList for msgid=%d, all=%d\n", |
"ldap_chkResponseList for msgid=%d, all=%d\n", |
msgid, all, 0 ); |
msgid, all, 0 ); |
lastlm = NULL; |
lastlm = &ld->ld_responses; |
for ( lm = ld->ld_responses; lm != NULL; lm = nextlm ) { |
for ( lm = ld->ld_responses; lm != NULL; lm = nextlm ) { |
nextlm = lm->lm_next; |
nextlm = lm->lm_next; |
|
|
Line 158 chkResponseList(
|
Line 158 chkResponseList(
|
msgid, 0, 0 ); |
msgid, 0, 0 ); |
ldap_mark_abandoned( ld, lm->lm_msgid ); |
ldap_mark_abandoned( ld, lm->lm_msgid ); |
|
|
if ( lastlm == NULL ) { |
/* Remove this entry from list */ |
/* Remove first entry in list */ |
*lastlm = nextlm; |
ld->ld_responses = lm->lm_next; |
|
} else { |
|
lastlm->lm_next = nextlm; |
|
} |
|
|
|
ldap_msgfree( lm ); |
ldap_msgfree( lm ); |
|
|
Line 173 chkResponseList(
|
Line 169 chkResponseList(
|
if ( msgid == LDAP_RES_ANY || lm->lm_msgid == msgid ) { |
if ( msgid == LDAP_RES_ANY || lm->lm_msgid == msgid ) { |
LDAPMessage *tmp; |
LDAPMessage *tmp; |
|
|
if ( all == LDAP_MSG_ONE || msgid == LDAP_RES_UNSOLICITED ) { |
if ( all == LDAP_MSG_ONE || all == LDAP_MSG_RECEIVED || |
|
msgid == LDAP_RES_UNSOLICITED ) { |
break; |
break; |
} |
} |
|
|
if ( lm->lm_chain == NULL ) { |
tmp = lm->lm_chain_tail; |
assert(lm->lm_chain_tail == lm); |
if ((tmp->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || |
if ((lm->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || |
(tmp->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) || |
(lm->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) || |
(tmp->lm_msgtype == LDAP_RES_INTERMEDIATE)) { |
(lm->lm_msgtype == LDAP_RES_INTERMEDIATE)) { |
tmp = NULL; |
tmp = NULL; |
|
} else { |
|
tmp = lm; |
|
} |
|
} else { |
|
assert(lm->lm_chain_tail != NULL); |
|
assert(lm->lm_chain_tail->lm_chain != NULL); |
|
if ((lm->lm_chain_tail->lm_chain->lm_msgtype |
|
== LDAP_RES_SEARCH_ENTRY) || |
|
(lm->lm_chain_tail->lm_chain->lm_msgtype |
|
== LDAP_RES_SEARCH_REFERENCE) || |
|
(lm->lm_chain_tail->lm_chain->lm_msgtype |
|
== LDAP_RES_INTERMEDIATE)) { |
|
tmp = NULL; |
|
} else { |
|
tmp = lm->lm_chain_tail->lm_chain; |
|
} |
|
} |
} |
|
|
if ( tmp == NULL ) { |
if ( tmp == NULL ) { |
Line 207 chkResponseList(
|
Line 187 chkResponseList(
|
|
|
break; |
break; |
} |
} |
lastlm = lm; |
lastlm = &lm->lm_next; |
} |
} |
|
|
if ( lm != NULL ) { |
if ( lm != NULL ) { |
/* Found an entry, remove it from the list */ |
/* Found an entry, remove it from the list */ |
if ( lastlm == NULL ) { |
|
ld->ld_responses = (all == LDAP_MSG_ONE && lm->lm_chain != NULL |
|
? lm->lm_chain : lm->lm_next); |
|
} else { |
|
lastlm->lm_next = (all == LDAP_MSG_ONE && lm->lm_chain != NULL |
|
? lm->lm_chain : lm->lm_next); |
|
} |
|
if ( all == LDAP_MSG_ONE && lm->lm_chain != NULL ) { |
if ( all == LDAP_MSG_ONE && lm->lm_chain != NULL ) { |
|
*lastlm = lm->lm_chain; |
lm->lm_chain->lm_next = lm->lm_next; |
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; |
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 != NULL); |
|
lm->lm_chain = NULL; |
lm->lm_chain = NULL; |
lm->lm_chain_tail = NULL; |
lm->lm_chain_tail = NULL; |
} |
} else { |
|
*lastlm = lm->lm_next; |
|
} |
lm->lm_next = NULL; |
lm->lm_next = NULL; |
} |
} |
|
|
Line 403 try_read1msg(
|
Line 378 try_read1msg(
|
|
|
#ifdef LDAP_CONNECTIONLESS |
#ifdef LDAP_CONNECTIONLESS |
LDAPMessage *tmp = NULL, *chain_head = NULL; |
LDAPMessage *tmp = NULL, *chain_head = NULL; |
int firstmsg = 1, moremsgs = 0, isv2 = 0; |
int moremsgs = 0, isv2 = 0; |
#endif |
#endif |
|
|
/* |
/* |
Line 806 lr->lr_res_matched ? lr->lr_res_matched
|
Line 781 lr->lr_res_matched ? lr->lr_res_matched
|
newmsg->lm_msgid = (int)id; |
newmsg->lm_msgid = (int)id; |
newmsg->lm_msgtype = tag; |
newmsg->lm_msgtype = tag; |
newmsg->lm_ber = ber; |
newmsg->lm_ber = ber; |
|
newmsg->lm_chain_tail = newmsg; |
|
|
#ifdef LDAP_CONNECTIONLESS |
#ifdef LDAP_CONNECTIONLESS |
/* CLDAP replies all fit in a single datagram. In LDAPv2 RFC1798 |
/* CLDAP replies all fit in a single datagram. In LDAPv2 RFC1798 |
Line 852 lr->lr_res_matched ? lr->lr_res_matched
|
Line 828 lr->lr_res_matched ? lr->lr_res_matched
|
if (ber_sockbuf_ctrl(sb, LBER_SB_OPT_DATA_READY, NULL)) ok=1; |
if (ber_sockbuf_ctrl(sb, LBER_SB_OPT_DATA_READY, NULL)) ok=1; |
} |
} |
/* set up response chain */ |
/* set up response chain */ |
if ( firstmsg ) { |
if ( tmp == NULL ) { |
firstmsg = 0; |
|
newmsg->lm_next = ld->ld_responses; |
newmsg->lm_next = ld->ld_responses; |
ld->ld_responses = newmsg; |
ld->ld_responses = newmsg; |
newmsg->lm_chain_tail = newmsg; |
|
chain_head = newmsg; |
chain_head = newmsg; |
} else { |
} else { |
assert( tmp != NULL ); |
|
tmp->lm_chain = newmsg; |
tmp->lm_chain = newmsg; |
chain_head->lm_chain_tail = tmp; |
|
} |
} |
|
chain_head->lm_chain_tail = newmsg; |
tmp = newmsg; |
tmp = newmsg; |
/* "ok" means there's more to parse */ |
/* "ok" means there's more to parse */ |
if (ok) { |
if (ok) { |
Line 883 lr->lr_res_matched ? lr->lr_res_matched
|
Line 856 lr->lr_res_matched ? lr->lr_res_matched
|
* first response off the head of the chain. |
* first response off the head of the chain. |
*/ |
*/ |
tmp->lm_chain = newmsg; |
tmp->lm_chain = newmsg; |
chain_head->lm_chain_tail = tmp; |
chain_head->lm_chain_tail = newmsg; |
*result = chkResponseList( ld, msgid, all ); |
*result = chkResponseList( ld, msgid, all ); |
ld->ld_errno = LDAP_SUCCESS; |
ld->ld_errno = LDAP_SUCCESS; |
return( (*result)->lm_msgtype ); |
return( (*result)->lm_msgtype ); |
Line 927 lr->lr_res_matched ? lr->lr_res_matched
|
Line 900 lr->lr_res_matched ? lr->lr_res_matched
|
|
|
newmsg->lm_next = ld->ld_responses; |
newmsg->lm_next = ld->ld_responses; |
ld->ld_responses = newmsg; |
ld->ld_responses = newmsg; |
newmsg->lm_chain_tail = newmsg; |
|
goto exit; |
goto exit; |
} |
} |
|
|
Line 935 lr->lr_res_matched ? lr->lr_res_matched
|
Line 907 lr->lr_res_matched ? lr->lr_res_matched
|
(long) newmsg->lm_msgid, (long) newmsg->lm_msgtype, 0 ); |
(long) newmsg->lm_msgid, (long) newmsg->lm_msgtype, 0 ); |
|
|
/* part of a search response - add to end of list of entries */ |
/* part of a search response - add to end of list of entries */ |
if (l->lm_chain == NULL) { |
l->lm_chain_tail->lm_chain = newmsg; |
assert(l->lm_chain_tail == l); |
l->lm_chain_tail = newmsg; |
l->lm_chain = newmsg; |
|
} else { |
|
assert(l->lm_chain_tail != NULL); |
|
assert(l->lm_chain_tail->lm_chain != NULL); |
|
if ((l->lm_chain_tail->lm_chain->lm_msgtype |
|
== LDAP_RES_SEARCH_ENTRY) || |
|
(l->lm_chain_tail->lm_chain->lm_msgtype |
|
== LDAP_RES_SEARCH_REFERENCE) || |
|
(l->lm_chain_tail->lm_chain->lm_msgtype |
|
== LDAP_RES_INTERMEDIATE)) { |
|
l->lm_chain_tail->lm_chain->lm_chain = newmsg; |
|
l->lm_chain_tail = l->lm_chain_tail->lm_chain; |
|
} else { |
|
/*FIXME: ldap_msgfree( l->lm_chain_tail->lm_chain );*/ |
|
l->lm_chain_tail->lm_chain = newmsg; |
|
} |
|
} |
|
|
|
/* return the whole chain if that's what we were looking for */ |
/* return the whole chain if that's what we were looking for */ |
if ( foundit ) { |
if ( foundit ) { |