]> git.sur5r.net Git - openldap/commitdiff
retry on ldap_result() with a timeout
authorPierangelo Masarati <ando@openldap.org>
Sat, 8 Jan 2005 09:19:51 +0000 (09:19 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 8 Jan 2005 09:19:51 +0000 (09:19 +0000)
servers/slapd/back-ldap/bind.c

index cd88c667f5e75d4a1aac5ed851b798d5d4c14010..a0e2783d4f642778f53c48a9bb9f0d6c7dad6990 100644 (file)
@@ -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 ) {