X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fresult.c;h=b6e8e75105f89b2ac02d22bc8d00d6bc888e0fd8;hb=7d13ef7e42f1514dd99878835a13a700da4f4b69;hp=a50d7c2a2971234132f6f8f0df143680f99f132d;hpb=0f30db1c46cf576230cd9397f0d5ad2892da7325;p=openldap diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index a50d7c2a29..b6e8e75105 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2010 The OpenLDAP Foundation. + * Copyright 1998-2012 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -338,6 +338,7 @@ wait4msg( } if ( lc_ready ) { LDAPConn *lnext; + int serviced = 0; rc = LDAP_MSG_X_KEEP_LOOKING; LDAP_MUTEX_LOCK( &ld->ld_req_mutex ); if ( ld->ld_requests && @@ -345,6 +346,7 @@ wait4msg( ldap_is_write_ready( ld, ld->ld_requests->lr_conn->lconn_sb ) ) { + serviced = 1; ldap_int_flush_request( ld, ld->ld_requests ); } for ( lc = ld->ld_conns; @@ -354,6 +356,7 @@ wait4msg( if ( lc->lconn_status == LDAP_CONNST_CONNECTED && ldap_is_read_ready( ld, lc->lconn_sb ) ) { + serviced = 1; /* Don't let it get freed out from under us */ ++lc->lconn_refcnt; rc = try_read1msg( ld, msgid, all, lc, result ); @@ -370,6 +373,9 @@ wait4msg( } } LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex ); + /* Quit looping if no one handled any events */ + if (!serviced) + rc = -1; } LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex ); } @@ -498,12 +504,8 @@ nextresp3: Debug( LDAP_DEBUG_CONNS, "ber_get_next failed.\n", 0, 0, 0 ); #endif -#ifdef EWOULDBLOCK if ( err == EWOULDBLOCK ) return LDAP_MSG_X_KEEP_LOOKING; -#endif -#ifdef EAGAIN if ( err == EAGAIN ) return LDAP_MSG_X_KEEP_LOOKING; -#endif ld->ld_errno = LDAP_SERVER_DOWN; --lc->lconn_refcnt; lc->lconn_status = 0; @@ -825,6 +827,7 @@ nextresp2: Debug( LDAP_DEBUG_TRACE, "read1msg: mark request completed, ld %p msgid %d\n", (void *)ld, lr->lr_msgid, 0); + tmplr = lr; while ( lr->lr_parent != NULL ) { merge_error_info( ld, lr->lr_parent, lr ); @@ -833,6 +836,12 @@ nextresp2: break; /* not completely done yet */ } } + /* ITS#6744: Original lr was refcounted when we retrieved it, + * must release it now that we're working with the parent + */ + if ( tmplr->lr_parent ) { + ldap_return_request( ld, tmplr, 0 ); + } /* Check if all requests are finished, lr is now parent */ tmplr = lr; @@ -877,7 +886,7 @@ nextresp2: } /* - * RF 4511 unsolicited (id == 0) responses + * RFC 4511 unsolicited (id == 0) responses * shouldn't necessarily end the connection */ if ( lc != NULL && id != 0 ) {