version 1.120, 2005/11/14 20:47:17
|
version 1.121, 2005/12/13 14:53:11
|
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.119 2005/11/12 17:42:04 ando Exp $ */ |
/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.120 2005/11/14 20:47:17 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 78 static ber_tag_t build_result_ber LDAP_P
|
Line 78 static ber_tag_t build_result_ber LDAP_P
|
static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); |
static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); |
static LDAPMessage * chkResponseList LDAP_P(( LDAP *ld, int msgid, int all)); |
static LDAPMessage * chkResponseList LDAP_P(( LDAP *ld, int msgid, int all)); |
|
|
|
#define LDAP_MSG_X_KEEP_LOOKING (-2) |
|
|
|
|
/* |
/* |
* ldap_result - wait for an ldap result response to a message from the |
* ldap_result - wait for an ldap result response to a message from the |
Line 255 wait4msg(
|
Line 257 wait4msg(
|
start_time = time( NULL ); |
start_time = time( NULL ); |
} |
} |
|
|
rc = -2; |
rc = LDAP_MSG_X_KEEP_LOOKING; |
while ( rc == -2 ) { |
while ( rc == LDAP_MSG_X_KEEP_LOOKING ) { |
#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", |
Line 315 wait4msg(
|
Line 317 wait4msg(
|
} |
} |
|
|
if ( rc == -1 ) { |
if ( rc == -1 ) { |
rc = -2; /* select interrupted: loop */ |
rc = LDAP_MSG_X_KEEP_LOOKING; /* select interrupted: loop */ |
} else { |
} else { |
rc = -2; |
rc = LDAP_MSG_X_KEEP_LOOKING; |
#ifdef LDAP_R_COMPILE |
#ifdef LDAP_R_COMPILE |
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); |
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); |
#endif |
#endif |
Line 332 wait4msg(
|
Line 334 wait4msg(
|
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); |
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); |
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex ); |
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex ); |
#endif |
#endif |
for ( lc = ld->ld_conns; rc == -2 && lc != NULL; |
for ( lc = ld->ld_conns; rc == LDAP_MSG_X_KEEP_LOOKING && lc != NULL; |
lc = nextlc ) |
lc = nextlc ) |
{ |
{ |
nextlc = lc->lconn_next; |
nextlc = lc->lconn_next; |
Line 357 wait4msg(
|
Line 359 wait4msg(
|
} |
} |
} |
} |
|
|
if ( rc == -2 && tvp != NULL ) { |
if ( rc == LDAP_MSG_X_KEEP_LOOKING && tvp != NULL ) { |
tmp_time = time( NULL ); |
tmp_time = time( NULL ); |
tv0.tv_sec -= ( tmp_time - start_time ); |
tv0.tv_sec -= ( tmp_time - start_time ); |
if ( tv0.tv_sec <= 0 ) { |
if ( tv0.tv_sec <= 0 ) { |
Line 459 nextresp3:
|
Line 461 nextresp3:
|
"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 LDAP_MSG_X_KEEP_LOOKING; |
#endif |
#endif |
#ifdef EAGAIN |
#ifdef EAGAIN |
if (errno == EAGAIN) return -2; |
if (errno == EAGAIN) return LDAP_MSG_X_KEEP_LOOKING; |
#endif |
#endif |
ld->ld_errno = LDAP_SERVER_DOWN; |
ld->ld_errno = LDAP_SERVER_DOWN; |
return -1; |
return -1; |
Line 487 retry_ber:
|
Line 489 retry_ber:
|
if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) { |
if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) { |
goto retry; |
goto retry; |
} |
} |
return( -2 ); /* continue looking */ |
return( LDAP_MSG_X_KEEP_LOOKING ); /* continue looking */ |
} |
} |
|
|
lr = ldap_find_request_by_msgid( ld, id ); |
lr = ldap_find_request_by_msgid( ld, id ); |
Line 517 nextresp2:
|
Line 519 nextresp2:
|
id = lr->lr_origid; |
id = lr->lr_origid; |
refer_cnt = 0; |
refer_cnt = 0; |
hadref = simple_request = 0; |
hadref = simple_request = 0; |
rc = -2; /* default is to keep looking (no response found) */ |
rc = LDAP_MSG_X_KEEP_LOOKING; /* default is to keep looking (no response found) */ |
lr->lr_res_msgtype = tag; |
lr->lr_res_msgtype = tag; |
|
|
/* |
/* |
Line 989 exit:
|
Line 991 exit:
|
if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) { |
if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) { |
goto retry; |
goto retry; |
} |
} |
return( -2 ); /* continue looking */ |
return( LDAP_MSG_X_KEEP_LOOKING ); /* continue looking */ |
} |
} |
|
|
|
|