mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
s/fprintf/Debug/ (ITS#4553); lock ld_conn_mutex before accessing conn(s)
This commit is contained in:
parent
86b566f029
commit
6b889b0a8a
2 changed files with 45 additions and 39 deletions
|
|
@ -647,37 +647,38 @@ ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all )
|
|||
LDAPConn *lc;
|
||||
char timebuf[32];
|
||||
|
||||
fprintf( stderr, "** ld %p Connection%s:\n", (void *)ld, all ? "s" : "" );
|
||||
Debug( LDAP_DEBUG_TRACE, "** ld %p Connection%s:\n", (void *)ld, all ? "s" : "", 0 );
|
||||
for ( lc = lconns; lc != NULL; lc = lc->lconn_next ) {
|
||||
if ( lc->lconn_server != NULL ) {
|
||||
fprintf( stderr, "* host: %s port: %d%s\n",
|
||||
Debug( LDAP_DEBUG_TRACE, "* host: %s port: %d%s\n",
|
||||
( lc->lconn_server->lud_host == NULL ) ? "(null)"
|
||||
: lc->lconn_server->lud_host,
|
||||
lc->lconn_server->lud_port, ( lc->lconn_sb ==
|
||||
ld->ld_sb ) ? " (default)" : "" );
|
||||
}
|
||||
fprintf( stderr, " refcnt: %d status: %s\n", lc->lconn_refcnt,
|
||||
( lc->lconn_status == LDAP_CONNST_NEEDSOCKET ) ?
|
||||
"NeedSocket" : ( lc->lconn_status ==
|
||||
LDAP_CONNST_CONNECTING ) ? "Connecting" : "Connected" );
|
||||
fprintf( stderr, " last used: %s",
|
||||
ldap_pvt_ctime( &lc->lconn_lastused, timebuf ));
|
||||
if( lc->lconn_rebind_inprogress ) {
|
||||
fprintf( stderr, " rebind in progress\n");
|
||||
if( lc->lconn_rebind_queue != NULL) {
|
||||
int i = 0;
|
||||
for( ;lc->lconn_rebind_queue[i] != NULL; i++) {
|
||||
int j = 0;
|
||||
for( ;lc->lconn_rebind_queue[i][j] != 0; j++) {
|
||||
fprintf( stderr, " queue %d entry %d - %s\n",
|
||||
i, j, lc->lconn_rebind_queue[i][j]);
|
||||
Debug( LDAP_DEBUG_TRACE, " refcnt: %d status: %s\n", lc->lconn_refcnt,
|
||||
( lc->lconn_status == LDAP_CONNST_NEEDSOCKET )
|
||||
? "NeedSocket" : ( lc->lconn_status == LDAP_CONNST_CONNECTING )
|
||||
? "Connecting" : "Connected", 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, " last used: %s%s\n",
|
||||
ldap_pvt_ctime( &lc->lconn_lastused, timebuf ),
|
||||
lc->lconn_rebind_inprogress ? " rebind in progress" : "", 0 );
|
||||
if ( lc->lconn_rebind_inprogress ) {
|
||||
if ( lc->lconn_rebind_queue != NULL) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; lc->lconn_rebind_queue[i] != NULL; i++ ) {
|
||||
int j;
|
||||
for( j = 0; lc->lconn_rebind_queue[i][j] != 0; j++ ) {
|
||||
Debug( LDAP_DEBUG_TRACE, " queue %d entry %d - %s\n",
|
||||
i, j, lc->lconn_rebind_queue[i][j] );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf( stderr, " queue is empty\n");
|
||||
Debug( LDAP_DEBUG_TRACE, " queue is empty\n", 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
Debug( LDAP_DEBUG_TRACE, "\n", 0, 0, 0 );
|
||||
if ( !all ) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -691,42 +692,37 @@ ldap_dump_requests_and_responses( LDAP *ld )
|
|||
LDAPRequest *lr;
|
||||
LDAPMessage *lm, *l;
|
||||
|
||||
#ifdef LDAP_R_COMPILE
|
||||
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
|
||||
#endif
|
||||
fprintf( stderr, "** ld %p Outstanding Requests:\n", (void *)ld );
|
||||
if (( lr = ld->ld_requests ) == NULL ) {
|
||||
fprintf( stderr, " Empty\n" );
|
||||
Debug( LDAP_DEBUG_TRACE, "** ld %p Outstanding Requests:\n",
|
||||
(void *)ld, 0, 0 );
|
||||
if ( ( lr = ld->ld_requests ) == NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, " Empty\n", 0, 0, 0 );
|
||||
}
|
||||
for ( ; lr != NULL; lr = lr->lr_next ) {
|
||||
fprintf( stderr, " * msgid %d, origid %d, status %s\n",
|
||||
Debug( LDAP_DEBUG_TRACE, " * msgid %d, origid %d, status %s\n",
|
||||
lr->lr_msgid, lr->lr_origid,
|
||||
( lr->lr_status == LDAP_REQST_INPROGRESS ) ? "InProgress" :
|
||||
( lr->lr_status == LDAP_REQST_CHASINGREFS ) ? "ChasingRefs" :
|
||||
( lr->lr_status == LDAP_REQST_NOTCONNECTED ) ? "NotConnected" :
|
||||
( lr->lr_status == LDAP_REQST_WRITING ) ? "Writing" :
|
||||
( lr->lr_status == LDAP_REQST_COMPLETED ) ? "RequestCompleted"
|
||||
: "InvalidStatus");
|
||||
fprintf( stderr, " outstanding referrals %d, parent count %d\n",
|
||||
lr->lr_outrefcnt, lr->lr_parentcnt );
|
||||
: "InvalidStatus" );
|
||||
Debug( LDAP_DEBUG_TRACE, " outstanding referrals %d, parent count %d\n",
|
||||
lr->lr_outrefcnt, lr->lr_parentcnt, 0 );
|
||||
}
|
||||
#ifdef LDAP_R_COMPILE
|
||||
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
|
||||
#endif
|
||||
fprintf( stderr, "** ld %p Response Queue:\n", (void *)ld );
|
||||
Debug( LDAP_DEBUG_TRACE, "** ld %p Response Queue:\n", (void *)ld, 0, 0 );
|
||||
if ( ( lm = ld->ld_responses ) == NULL ) {
|
||||
fprintf( stderr, " Empty\n" );
|
||||
Debug( LDAP_DEBUG_TRACE, " Empty\n", 0, 0, 0 );
|
||||
}
|
||||
for ( ; lm != NULL; lm = lm->lm_next ) {
|
||||
fprintf( stderr, " * msgid %d, type %lu\n",
|
||||
lm->lm_msgid, (unsigned long) lm->lm_msgtype );
|
||||
Debug( LDAP_DEBUG_TRACE, " * msgid %d, type %lu\n",
|
||||
lm->lm_msgid, (unsigned long)lm->lm_msgtype, 0 );
|
||||
if ( ( l = lm->lm_chain ) != NULL ) {
|
||||
fprintf( stderr, " chained responses:\n" );
|
||||
Debug( LDAP_DEBUG_TRACE, " chained responses:\n", 0, 0, 0 );
|
||||
for ( ; l != NULL; l = l->lm_chain ) {
|
||||
fprintf( stderr,
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
" * msgid %d, type %lu\n",
|
||||
l->lm_msgid,
|
||||
(unsigned long) l->lm_msgtype );
|
||||
(unsigned long)l->lm_msgtype, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,8 +273,18 @@ wait4msg(
|
|||
if ( ldap_debug & LDAP_DEBUG_TRACE ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "wait4msg continue ld %p msgid %d all %d\n",
|
||||
(void *)ld, msgid, all );
|
||||
#ifdef LDAP_R_COMPILE
|
||||
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
|
||||
#endif
|
||||
ldap_dump_connection( ld, ld->ld_conns, 1 );
|
||||
#ifdef LDAP_R_COMPILE
|
||||
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
|
||||
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
|
||||
#endif
|
||||
ldap_dump_requests_and_responses( ld );
|
||||
#ifdef LDAP_R_COMPILE
|
||||
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
|
||||
#endif
|
||||
}
|
||||
#endif /* LDAP_DEBUG */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue