]> git.sur5r.net Git - openldap/commitdiff
gently handle LDAP_UNAVAILABLE for a few times
authorPierangelo Masarati <ando@openldap.org>
Fri, 4 Nov 2005 14:49:59 +0000 (14:49 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 4 Nov 2005 14:49:59 +0000 (14:49 +0000)
tests/progs/slapd-addel.c
tests/progs/slapd-modify.c
tests/progs/slapd-modrdn.c

index 082a7aa3d530e4ab770ca9d34304971ba74aeef4..163910bb93ab6807e23951c4113dbbb8169d75bc 100644 (file)
@@ -328,12 +328,18 @@ retry:;
                rc = ldap_add_s( ld, entry, attrs );
                if ( rc != LDAP_SUCCESS ) {
                        ldap_perror( ld, "ldap_add" );
-                       if ( rc == LDAP_BUSY && do_retry > 0 ) {
-                               do_retry--;
-                               goto retry;
-                       }
-                       break;
+                       switch ( rc ) {
+                       case LDAP_BUSY:
+                       case LDAP_UNAVAILABLE:
+                               if ( do_retry > 0 ) {
+                                       do_retry--;
+                                       goto retry;
+                               }
+                               /* fall thru */
 
+                       default:
+                               goto done;
+                       }
                }
 
 #if 0
@@ -346,14 +352,22 @@ retry:;
                rc = ldap_delete_s( ld, entry );
                if ( rc != LDAP_SUCCESS ) {
                        ldap_perror( ld, "ldap_delete" );
-                       if ( rc == LDAP_BUSY && do_retry > 0 ) {
-                               do_retry--;
-                               goto retry;
+                       switch ( rc ) {
+                       case LDAP_BUSY:
+                       case LDAP_UNAVAILABLE:
+                               if ( do_retry > 0 ) {
+                                       do_retry--;
+                                       goto retry;
+                               }
+                               /* fall thru */
+
+                       default:
+                               goto done;
                        }
-                       break;
                }
        }
 
+done:;
        fprintf( stderr, " PID=%ld - Add/Delete done (%d).\n", (long) pid, rc );
 
        ldap_unbind( ld );
index c0484dbc5cfa7d6611ff3971a5bbfe17a176b435..a2f275d9f8705a5cf73c7872df500761c327e5b2 100644 (file)
@@ -232,16 +232,26 @@ retry:;
                rc = ldap_modify_s( ld, entry, mods );
                if ( rc != LDAP_SUCCESS ) {
                        ldap_perror( ld, "ldap_modify" );
-                       if ( rc == LDAP_BUSY && do_retry > 0 ) {
-                               do_retry--;
-                               goto retry;
+                       switch ( rc ) {
+                       case LDAP_NO_SUCH_OBJECT:
+                               break;
+
+                       case LDAP_BUSY:
+                       case LDAP_UNAVAILABLE:
+                               if ( do_retry > 0 ) {
+                                       do_retry--;
+                                       goto retry;
+                               }
+                               /* fall thru */
+
+                       default:
+                               goto done;
                        }
-                       if ( rc != LDAP_NO_SUCH_OBJECT ) break;
-                       continue;
                }
 
        }
 
+done:;
        fprintf( stderr, " PID=%ld - Modify done (%d).\n", (long) pid, rc );
 
        ldap_unbind( ld );
index 06b513044269dbbc68033bde43a79533149ab6bf..4378fe29edf2902c85762d098ef0ae9a8911b4c6 100644 (file)
@@ -211,25 +211,47 @@ retry:;
                rc = ldap_modrdn2_s( ld, DNs[0], rdns[0], 0 );
                if ( rc != LDAP_SUCCESS ) {
                        ldap_perror( ld, "ldap_modrdn" );
-                       if ( rc == LDAP_BUSY && do_retry > 0 ) {
-                               do_retry--;
-                               goto retry;
+                       switch ( rc ) {
+                       case LDAP_NO_SUCH_OBJECT:
+                               /* NOTE: this likely means
+                                * the second modrdn failed
+                                * during the previous round... */
+                               break;
+
+                       case LDAP_BUSY:
+                       case LDAP_UNAVAILABLE:
+                               if ( do_retry > 0 ) {
+                                       do_retry--;
+                                       goto retry;
+                               }
+                               /* fall thru */
+
+                       default:
+                               goto done;
                        }
-                       if ( rc != LDAP_NO_SUCH_OBJECT ) break;
-                       continue;
                }
                rc = ldap_modrdn2_s( ld, DNs[1], rdns[1], 1 );
                if ( rc != LDAP_SUCCESS ) {
                        ldap_perror( ld, "ldap_modrdn" );
-                       if ( rc == LDAP_BUSY && do_retry > 0 ) {
-                               do_retry--;
-                               goto retry;
+                       switch ( rc ) {
+                       case LDAP_NO_SUCH_OBJECT:
+                               break;
+
+                       case LDAP_BUSY:
+                       case LDAP_UNAVAILABLE:
+                               if ( do_retry > 0 ) {
+                                       do_retry--;
+                                       goto retry;
+                               }
+                               /* fall thru */
+
+                       default:
+                               goto done;
                        }
-                       if ( rc != LDAP_NO_SUCH_OBJECT ) break;
-                       continue;
                }
        }
 
+done:;
        fprintf( stderr, " PID=%ld - Modrdn done (%d).\n", (long) pid, rc );
 
        ldap_unbind( ld );