version 1.119, 2005/11/12 17:42:04
|
version 1.120, 2005/11/14 20:47:17
|
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.118 2005/10/11 22:31:05 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.119 2005/11/12 17:42:04 ando 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 111 ldap_result(
|
Line 111 ldap_result(
|
assert( ld != NULL ); |
assert( ld != NULL ); |
assert( result != NULL ); |
assert( result != NULL ); |
|
|
Debug( LDAP_DEBUG_TRACE, "ldap_result ld %p msgid %d\n", ld, msgid, 0 ); |
Debug( LDAP_DEBUG_TRACE, "ldap_result ld %p msgid %d\n", (void *)ld, msgid, 0 ); |
|
|
#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 ); |
Line 147 chkResponseList(
|
Line 147 chkResponseList(
|
|
|
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"ldap_chkResponseList ld %p msgid %d all %d\n", |
"ldap_chkResponseList ld %p msgid %d all %d\n", |
ld, msgid, all ); |
(void *)ld, msgid, all ); |
lastlm = &ld->ld_responses; |
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 207 chkResponseList(
|
Line 207 chkResponseList(
|
#ifdef LDAP_DEBUG |
#ifdef LDAP_DEBUG |
if( lm == NULL) { |
if( lm == NULL) { |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"ldap_chkResponseList returns ld %p NULL\n", ld, 0, 0); |
"ldap_chkResponseList returns ld %p NULL\n", (void *)ld, 0, 0); |
} else { |
} else { |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"ldap_chkResponseList returns ld %p msgid %d, type 0x%02lu\n", |
"ldap_chkResponseList returns ld %p msgid %d, type 0x%02lu\n", |
ld, lm->lm_msgid, (unsigned long) lm->lm_msgtype); |
(void *)ld, lm->lm_msgid, (unsigned long) lm->lm_msgtype); |
} |
} |
#endif |
#endif |
return lm; |
return lm; |
Line 239 wait4msg(
|
Line 239 wait4msg(
|
#ifdef LDAP_DEBUG |
#ifdef LDAP_DEBUG |
if ( timeout == NULL ) { |
if ( timeout == NULL ) { |
Debug( LDAP_DEBUG_TRACE, "wait4msg ld %p msgid %d (infinite timeout)\n", |
Debug( LDAP_DEBUG_TRACE, "wait4msg ld %p msgid %d (infinite timeout)\n", |
ld, msgid, 0 ); |
(void *)ld, msgid, 0 ); |
} else { |
} else { |
Debug( LDAP_DEBUG_TRACE, "wait4msg ld %p msgid %d (timeout %ld usec)\n", |
Debug( LDAP_DEBUG_TRACE, "wait4msg ld %p msgid %d (timeout %ld usec)\n", |
ld, msgid, (long)timeout->tv_sec * 1000000 + timeout->tv_usec ); |
(void *)ld, msgid, (long)timeout->tv_sec * 1000000 + timeout->tv_usec ); |
} |
} |
#endif /* LDAP_DEBUG */ |
#endif /* LDAP_DEBUG */ |
|
|
Line 260 wait4msg(
|
Line 260 wait4msg(
|
#ifdef LDAP_DEBUG |
#ifdef LDAP_DEBUG |
if ( ldap_debug & LDAP_DEBUG_TRACE ) { |
if ( ldap_debug & LDAP_DEBUG_TRACE ) { |
Debug( LDAP_DEBUG_TRACE, "wait4msg continue ld %p msgid %d all %d\n", |
Debug( LDAP_DEBUG_TRACE, "wait4msg continue ld %p msgid %d all %d\n", |
ld, msgid, all ); |
(void *)ld, msgid, all ); |
ldap_dump_connection( ld, ld->ld_conns, 1 ); |
ldap_dump_connection( ld, ld->ld_conns, 1 ); |
ldap_dump_requests_and_responses( ld ); |
ldap_dump_requests_and_responses( ld ); |
} |
} |
Line 368 wait4msg(
|
Line 368 wait4msg(
|
tv.tv_sec = tv0.tv_sec; |
tv.tv_sec = tv0.tv_sec; |
|
|
Debug( LDAP_DEBUG_TRACE, "wait4msg ld %p %ld secs to go\n", |
Debug( LDAP_DEBUG_TRACE, "wait4msg ld %p %ld secs to go\n", |
ld, (long) tv.tv_sec, 0 ); |
(void *)ld, (long) tv.tv_sec, 0 ); |
start_time = tmp_time; |
start_time = tmp_time; |
} |
} |
} |
} |
Line 417 try_read1msg(
|
Line 417 try_read1msg(
|
assert( lcp != NULL ); |
assert( lcp != NULL ); |
assert( *lcp != NULL ); |
assert( *lcp != NULL ); |
|
|
Debug( LDAP_DEBUG_TRACE, "read1msg: ld %p msgid %d all %d\n", ld, msgid, all ); |
Debug( LDAP_DEBUG_TRACE, "read1msg: ld %p msgid %d all %d\n", |
|
(void *)ld, msgid, all ); |
|
|
lc = *lcp; |
lc = *lcp; |
|
|
Line 455 nextresp3:
|
Line 456 nextresp3:
|
if ( tag == LBER_DEFAULT) { |
if ( tag == LBER_DEFAULT) { |
#ifdef LDAP_DEBUG |
#ifdef LDAP_DEBUG |
Debug( LDAP_DEBUG_CONNS, |
Debug( LDAP_DEBUG_CONNS, |
"ber_get_next failed.\n", 0, 0, 0 ); |
"ber_get_next failed.\n", 0, 0, 0 ); |
#endif |
#endif |
#ifdef EWOULDBLOCK |
#ifdef EWOULDBLOCK |
if (errno==EWOULDBLOCK) return -2; |
if (errno==EWOULDBLOCK) return -2; |
Line 480 nextresp3:
|
Line 481 nextresp3:
|
/* if it's been abandoned, toss it */ |
/* if it's been abandoned, toss it */ |
if ( ldap_abandoned( ld, id ) ) { |
if ( ldap_abandoned( ld, id ) ) { |
Debug( LDAP_DEBUG_ANY, "abandoned ld %p msgid %ld\n", |
Debug( LDAP_DEBUG_ANY, "abandoned ld %p msgid %ld\n", |
ld, (long) id, 0); |
(void *)ld, (long) id, 0); |
retry_ber: |
retry_ber: |
ber_free( ber, 1 ); |
ber_free( ber, 1 ); |
if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) { |
if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) { |
Line 492 retry_ber:
|
Line 493 retry_ber:
|
lr = ldap_find_request_by_msgid( ld, id ); |
lr = ldap_find_request_by_msgid( ld, id ); |
if ( lr == NULL ) { |
if ( lr == NULL ) { |
Debug( LDAP_DEBUG_ANY, |
Debug( LDAP_DEBUG_ANY, |
"no request for response on ld %p msgid %ld (tossing)\n", |
"no request for response on ld %p msgid %ld (tossing)\n", |
ld, (long) id, 0 ); |
(void *)ld, (long) id, 0 ); |
goto retry_ber; |
goto retry_ber; |
} |
} |
#ifdef LDAP_CONNECTIONLESS |
#ifdef LDAP_CONNECTIONLESS |
Line 511 nextresp2:
|
Line 512 nextresp2:
|
|
|
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"read1msg: ld %p msgid %ld message type %s\n", |
"read1msg: ld %p msgid %ld message type %s\n", |
ld, (long) lr->lr_msgid, ldap_int_msgtype2str( tag )); |
(void *)ld, (long) lr->lr_msgid, ldap_int_msgtype2str( tag )); |
|
|
id = lr->lr_origid; |
id = lr->lr_origid; |
refer_cnt = 0; |
refer_cnt = 0; |
Line 609 nextresp2:
|
Line 610 nextresp2:
|
rc = LDAP_DECODING_ERROR; |
rc = LDAP_DECODING_ERROR; |
lr->lr_status = LDAP_REQST_COMPLETED; |
lr->lr_status = LDAP_REQST_COMPLETED; |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"read1msg: referral decode error, mark request completed, ld %p msgid %d\n", |
"read1msg: referral decode error, mark request completed, ld %p msgid %d\n", |
ld, lr->lr_msgid, 0); |
(void *)ld, lr->lr_msgid, 0); |
} else { |
} else { |
/* Chase the referral |
/* Chase the referral |
* Note: refs arrary is freed by ldap_chase_v3referrals |
* Note: refs arrary is freed by ldap_chase_v3referrals |
Line 619 nextresp2:
|
Line 620 nextresp2:
|
0, &lr->lr_res_error, &hadref ); |
0, &lr->lr_res_error, &hadref ); |
lr->lr_status = LDAP_REQST_COMPLETED; |
lr->lr_status = LDAP_REQST_COMPLETED; |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"read1msg: referral chased, mark request completed, ld %p msgid %d\n", |
"read1msg: referral chased, mark request completed, ld %p msgid %d\n", |
ld, lr->lr_msgid, 0); |
(void *)ld, lr->lr_msgid, 0); |
if( refer_cnt > 0) { |
if( refer_cnt > 0) { |
/* Referral successfully chased */ |
/* Referral successfully chased */ |
v3ref = V3REF_SUCCESS; |
v3ref = V3REF_SUCCESS; |
Line 742 nextresp2:
|
Line 743 nextresp2:
|
} |
} |
|
|
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"read1msg: ld %p %d new referrals\n", ld, refer_cnt, 0 ); |
"read1msg: ld %p %d new referrals\n", |
|
(void *)ld, refer_cnt, 0 ); |
|
|
if ( refer_cnt != 0 ) { /* chasing referrals */ |
if ( refer_cnt != 0 ) { /* chasing referrals */ |
ber_free( ber, 1 ); |
ber_free( ber, 1 ); |
Line 763 nextresp2:
|
Line 765 nextresp2:
|
|
|
lr->lr_status = LDAP_REQST_COMPLETED; /* declare this request done */ |
lr->lr_status = LDAP_REQST_COMPLETED; /* declare this request done */ |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"read1msg: mark request completed, ld %p msgid %d\n", ld, lr->lr_msgid, 0); |
"read1msg: mark request completed, ld %p msgid %d\n", |
|
(void *)ld, lr->lr_msgid, 0); |
while ( lr->lr_parent != NULL ) { |
while ( lr->lr_parent != NULL ) { |
merge_error_info( ld, lr->lr_parent, lr ); |
merge_error_info( ld, lr->lr_parent, lr ); |
|
|
Line 791 nextresp2:
|
Line 794 nextresp2:
|
id = lr->lr_msgid; |
id = lr->lr_msgid; |
tag = lr->lr_res_msgtype; |
tag = lr->lr_res_msgtype; |
Debug( LDAP_DEBUG_ANY, "request done: ld %p msgid %ld\n", |
Debug( LDAP_DEBUG_ANY, "request done: ld %p msgid %ld\n", |
ld, (long) id, 0 ); |
(void *)ld, (long) id, 0 ); |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"res_errno: %d, res_error: <%s>, res_matched: <%s>\n", |
"res_errno: %d, res_error: <%s>, res_matched: <%s>\n", |
lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "", |
lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "", |
Line 963 lr->lr_res_matched ? lr->lr_res_matched
|
Line 966 lr->lr_res_matched ? lr->lr_res_matched
|
} |
} |
|
|
Debug( LDAP_DEBUG_TRACE, "adding response ld %p msgid %ld type %ld:\n", |
Debug( LDAP_DEBUG_TRACE, "adding response ld %p msgid %ld type %ld:\n", |
ld, (long) newmsg->lm_msgid, (long) newmsg->lm_msgtype ); |
(void *)ld, (long) newmsg->lm_msgid, (long) newmsg->lm_msgtype ); |
|
|
/* part of a search response - add to end of list of entries */ |
/* part of a search response - add to end of list of entries */ |
l->lm_chain_tail->lm_chain = newmsg; |
l->lm_chain_tail->lm_chain = newmsg; |