Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix memory leak when clients disconnect (sleeper list isn't pruned)

CPAN RT# 70728

Thank you Marsh Yamazaki
  • Loading branch information...
commit e51a6d35c08c0cba0d10fb43115c744a64440d6a 1 parent c09b680
Jonathan Steinert authored Jonathan Steinert committed
Showing with 15 additions and 0 deletions.
  1. +3 −0  CHANGES
  2. +12 −0 lib/Gearman/Server/Client.pm
View
3  CHANGES
@@ -1,3 +1,6 @@
+ * Fix memory leak when clients disconnect (sleeper list isn't pruned).
+ Fixes CPAN RT 70728 (Marsh Yamazaki)
+
1.11 2010-01-17
* Don't get stuck in the wakeup loop. Dummy.
View
12 lib/Gearman/Server/Client.pm
@@ -92,9 +92,21 @@ sub close {
# Remove self from sleepers, otherwise it will be leaked if another worker
# for the job never connects.
my $sleepers = $self->{server}{sleepers};
+ my $sleepers_list = $self->{server}{sleepers_list};
for my $job (@{ $self->{can_do_list} }) {
my $sleeping = $sleepers->{$job};
delete $sleeping->{$self};
+
+ my $new_sleepers_list;
+ for my $client (@{$sleepers_list->{$job}}) {
+ push @{$new_sleepers_list}, $client unless $sleeping->{$client};
+ }
+ if ($new_sleepers_list) {
+ $self->{server}{sleepers_list}->{$job} = $new_sleepers_list;
+ } else {
+ delete $self->{server}{sleepers_list}->{$job};
+ }
+
delete $sleepers->{$job} unless %$sleeping;
}
Please sign in to comment.
Something went wrong with that request. Please try again.