From 4d8267595ffb1b25d084ab41806d25585c311190 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 8 Jan 2005 09:19:51 +0000 Subject: [PATCH] retry on ldap_result() with a timeout --- servers/slapd/back-ldap/bind.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index cd88c667f5..a0e2783d4f 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -428,17 +428,30 @@ ldap_back_op_result( * to a successful state, get the error from the * remote server response */ if ( ERR_OK( rs->sr_err ) ) { + int rc; + struct timeval tv = { 0, 0 }; + +retry:; /* if result parsing fails, note the failure reason */ - if ( ldap_result( lc->lc_ld, msgid, 1, NULL, &res ) == -1 ) { + switch ( ldap_result( lc->lc_ld, msgid, 1, &tv, &res ) ) { + case 0: + tv.tv_sec = 0; + tv.tv_usec = 100000; /* 0.1 s */ + ldap_pvt_thread_yield(); + goto retry; + + case -1: ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err ); + break; + /* otherwise get the result; if it is not * LDAP_SUCCESS, record it in the reply * structure (this includes * LDAP_COMPARE_{TRUE|FALSE}) */ - } else { - int rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, + default: + rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, &match, &text, NULL, NULL, 1 ); rs->sr_text = text; if ( rc != LDAP_SUCCESS ) { -- 2.39.5