From 0d35dcf83a45a1498724cc1d8c18226d3fffec46 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 17 Aug 2005 08:17:30 +0000 Subject: [PATCH] better handling of bind retry --- tests/progs/slapd-addel.c | 14 +++++++++++--- tests/progs/slapd-modify.c | 14 +++++++++++--- tests/progs/slapd-modrdn.c | 14 +++++++++++--- tests/progs/slapd-read.c | 14 +++++++++++--- tests/progs/slapd-search.c | 16 ++++++++++++---- 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index c96cdccd35..6b8caacc06 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -291,9 +291,17 @@ retry:; rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ); if ( rc != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_bind" ); - if ( rc == LDAP_BUSY && do_retry > 0 ) { - do_retry--; - goto retry; + switch ( rc ) { + case LDAP_BUSY: + case LDAP_UNAVAILABLE: + if ( do_retry == 1 ) { + do_retry = 0; + sleep( 1 ); + goto retry; + } + /* fallthru */ + default: + break; } exit( EXIT_FAILURE ); } diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 37e45ec19e..b639df5539 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -185,9 +185,17 @@ retry:; rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ); if ( rc != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_bind" ); - if ( rc == LDAP_BUSY && do_retry > 0 ) { - do_retry--; - goto retry; + switch ( rc ) { + case LDAP_BUSY: + case LDAP_UNAVAILABLE: + if ( do_retry == 1 ) { + do_retry = 0; + sleep( 1 ); + goto retry; + } + /* fallthru */ + default: + break; } exit( EXIT_FAILURE ); } diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index 60e85fa77b..2e95ddfa03 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -177,9 +177,17 @@ retry:; rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ); if ( rc != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_bind" ); - if ( rc == LDAP_BUSY && do_retry > 0 ) { - do_retry--; - goto retry; + switch ( rc ) { + case LDAP_BUSY: + case LDAP_UNAVAILABLE: + if ( do_retry == 1 ) { + do_retry = 0; + sleep( 1 ); + goto retry; + } + /* fallthru */ + default: + break; } exit( EXIT_FAILURE ); } diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c index c3c09758b5..e2c0768679 100644 --- a/tests/progs/slapd-read.c +++ b/tests/progs/slapd-read.c @@ -140,9 +140,17 @@ retry:; rc = ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ); if ( rc != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_bind" ); - if ( rc == LDAP_BUSY && do_retry > 0 ) { - do_retry--; - goto retry; + switch ( rc ) { + case LDAP_BUSY: + case LDAP_UNAVAILABLE: + if ( do_retry == 1 ) { + do_retry = 0; + sleep( 1 ); + goto retry; + } + /* fallthru */ + default: + break; } exit( EXIT_FAILURE ); } diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c index de42211fca..25488b816c 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -157,11 +157,19 @@ retry:; rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ); if ( rc != LDAP_SUCCESS ) { - if ( rc == LDAP_BUSY && do_retry == 1 ) { - do_retry = 0; - goto retry; - } ldap_perror( ld, "ldap_bind" ); + switch ( rc ) { + case LDAP_BUSY: + case LDAP_UNAVAILABLE: + if ( do_retry == 1 ) { + do_retry = 0; + sleep( 1 ); + goto retry; + } + /* fallthru */ + default: + break; + } exit( EXIT_FAILURE ); } -- 2.39.5