Browse files

Fixed pool release bug in _wait_for_agreement

  • Loading branch information...
1 parent e4a6b5e commit e514d3744c4563ebb2f63502e7ae52c7c2a7e93b @fmgoncalves committed Nov 11, 2011
Showing with 9 additions and 6 deletions.
  1. +1 −1 lib/Cassandra/Pool.pm
  2. +8 −5 lib/Cassandra/Simple.pm
View
2 lib/Cassandra/Pool.pm
@@ -55,7 +55,7 @@ sub new {
next if $opt->{server_name} eq $_;
my %params = %$opt;
$params{server_name} = $_;
- $loadbalancer->add_pool(ResourcePool->new(Cassandra::Pool::CassandraServerFactory->new(\%params)));
+ $loadbalancer->add_pool(ResourcePool->new(Cassandra::Pool::CassandraServerFactory->new(\%params), PreCreate => 2));
}
$self->{pool} = $loadbalancer;
View
13 lib/Cassandra/Simple.pm
@@ -172,12 +172,15 @@ sub _wait_for_agreement {
my $self = shift;
my $cl = $self->pool->get();
- while ( 1 != scalar keys %{ $cl->describe_schema_versions() } ) {
- sleep 0.25;
- }
-
+ eval {
+ while ( 1 != scalar keys %{ $cl->describe_schema_versions() } )
+ {
+ sleep 0.25;
+ }
+ $self->pool->put($cl);
+ };
+ if ($@) { print Dumper $@;$self->pool->fail($cl); }
}
-
#### API methods ####
=head2 get

0 comments on commit e514d37

Please sign in to comment.