mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
Simplify lm_chain_tail handling, support LDAP_MSG_RECEIVED
Drop support for LDAP_MORE_RESULTS_TO_RETURN
This commit is contained in:
parent
fc79957ad6
commit
a8a23840b8
@ -273,26 +273,12 @@ ldap_parse_result(
|
|||||||
#ifdef LDAP_R_COMPILE
|
#ifdef LDAP_R_COMPILE
|
||||||
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
|
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
|
||||||
#endif
|
#endif
|
||||||
/* Find the next result... */
|
/* Find the result, last msg in chain... */
|
||||||
if ( r->lm_chain == NULL ) {
|
lm = r->lm_chain_tail;
|
||||||
if ((r->lm_msgtype == LDAP_RES_SEARCH_ENTRY) ||
|
if ((lm->lm_msgtype == LDAP_RES_SEARCH_ENTRY) ||
|
||||||
(r->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) ||
|
(lm->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) ||
|
||||||
(r->lm_msgtype == LDAP_RES_INTERMEDIATE)) {
|
(lm->lm_msgtype == LDAP_RES_INTERMEDIATE)) {
|
||||||
lm = NULL;
|
lm = NULL;
|
||||||
} else {
|
|
||||||
lm = r;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((r->lm_chain_tail->lm_chain->lm_msgtype
|
|
||||||
== LDAP_RES_SEARCH_ENTRY) ||
|
|
||||||
(r->lm_chain_tail->lm_chain->lm_msgtype
|
|
||||||
== LDAP_RES_SEARCH_REFERENCE) ||
|
|
||||||
(r->lm_chain_tail->lm_chain->lm_msgtype
|
|
||||||
== LDAP_RES_INTERMEDIATE)) {
|
|
||||||
lm = NULL;
|
|
||||||
} else {
|
|
||||||
lm = r->lm_chain_tail->lm_chain;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( lm == NULL ) {
|
if( lm == NULL ) {
|
||||||
@ -396,28 +382,6 @@ ldap_parse_result(
|
|||||||
if( referralsp != NULL) {
|
if( referralsp != NULL) {
|
||||||
*referralsp = ldap_value_dup( ld->ld_referrals );
|
*referralsp = ldap_value_dup( ld->ld_referrals );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the next result... */
|
|
||||||
lm = lm->lm_chain;
|
|
||||||
if ( lm ) {
|
|
||||||
if ( lm->lm_chain == NULL ) {
|
|
||||||
if ((lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) &&
|
|
||||||
(lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE) &&
|
|
||||||
(lm->lm_msgtype != LDAP_RES_INTERMEDIATE)) {
|
|
||||||
/* more results to return */
|
|
||||||
errcode = LDAP_MORE_RESULTS_TO_RETURN;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
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)) {
|
|
||||||
errcode = LDAP_MORE_RESULTS_TO_RETURN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( freeit ) {
|
if ( freeit ) {
|
||||||
|
@ -137,7 +137,7 @@ 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
|
||||||
@ -148,7 +148,7 @@ 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;
|
||||||
|
|
||||||
@ -158,12 +158,8 @@ 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 );
|
||||||
|
|
||||||
@ -173,32 +169,16 @@ 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 ) {
|
||||||
@ -207,24 +187,19 @@ 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;
|
||||||
}
|
}
|
||||||
@ -403,7 +378,7 @@ 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
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -806,6 +781,7 @@ 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
|
||||||
@ -852,17 +828,14 @@ 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) {
|
||||||
@ -883,7 +856,7 @@ 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 );
|
||||||
@ -927,7 +900,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,25 +907,8 @@ 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) {
|
|
||||||
assert(l->lm_chain_tail == l);
|
|
||||||
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;
|
l->lm_chain_tail->lm_chain = newmsg;
|
||||||
}
|
l->lm_chain_tail = 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 ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user