Attempt to retry the operation on failure.
Less-than-optimal behavior reported by Alexander Perlis <aperlis@math.lsu.edu>. FossilOrigin-Name: ccbc3dc1b0e9f73b6b73f2c9ab1bd2d30f798c9d8e7efbdb8b0f178045239b96
This commit is contained in:
parent
f89ceae24e
commit
430b51643d
1 changed files with 18 additions and 8 deletions
26
shelldap
26
shelldap
|
|
@ -681,20 +681,30 @@ sub search
|
||||||
attrs => $opts->{'attrs'} || ['*']
|
attrs => $opts->{'attrs'} || ['*']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# since search is used just about everywhere, this seems like
|
||||||
|
# a pretty good place to check for connection errors and try
|
||||||
|
# to re-establish a connection.
|
||||||
|
#
|
||||||
|
if ( $s->code() != 0 ) {
|
||||||
|
$self->debug( "Error ". $s->code() . ", retrying.\n" );
|
||||||
|
$self->{'ldap'} = undef;
|
||||||
|
|
||||||
|
$s = $self->ldap->search(
|
||||||
|
base => $opts->{'base'},
|
||||||
|
filter => $opts->{'filter'},
|
||||||
|
scope => $opts->{'scope'},
|
||||||
|
timelimit => $conf->{'timeout'},
|
||||||
|
typesonly => ! $opts->{'vals'},
|
||||||
|
attrs => $opts->{'attrs'} || ['*']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
my $rv = {
|
my $rv = {
|
||||||
code => $s->code(),
|
code => $s->code(),
|
||||||
message => $s->error(),
|
message => $s->error(),
|
||||||
entries => []
|
entries => []
|
||||||
};
|
};
|
||||||
|
|
||||||
# since search is used just about everywhere, this seems like
|
|
||||||
# a pretty good place to check for connection errors.
|
|
||||||
#
|
|
||||||
# check for a lost connection, kill cached object so we
|
|
||||||
# try to reconnect on the next search.
|
|
||||||
#
|
|
||||||
$self->{'ldap'} = undef if $s->code() == LDAP_SERVER_DOWN;
|
|
||||||
|
|
||||||
$rv->{'entries'} =
|
$rv->{'entries'} =
|
||||||
$opts->{'scope'} eq 'base' ? [ $s->shift_entry() ] : [ $s->entries() ];
|
$opts->{'scope'} eq 'base' ? [ $s->shift_entry() ] : [ $s->entries() ];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue