From d08257407d7bed8abe9bdf174965aa84ea8144eb Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 4 Nov 2005 14:49:59 +0000 Subject: [PATCH] gently handle LDAP_UNAVAILABLE for a few times --- tests/progs/slapd-addel.c | 32 +++++++++++++++++++++-------- tests/progs/slapd-modify.c | 20 +++++++++++++----- tests/progs/slapd-modrdn.c | 42 +++++++++++++++++++++++++++++--------- 3 files changed, 70 insertions(+), 24 deletions(-) diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index 082a7aa3d5..163910bb93 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -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 ); diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index c0484dbc5c..a2f275d9f8 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -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 ); diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index 06b5130442..4378fe29ed 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -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 ); -- 2.39.5