5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-25 05:33:49 +03:00

daemon: refactor and cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2017-11-10 12:09:28 +01:00 committed by Wolfgang Bumiller
parent d0138dbaca
commit 0da5a3e43b

View File

@ -146,11 +146,7 @@ my $start_workers = sub {
return if $self->{terminate};
my $count = 0;
foreach my $cpid (keys %{$self->{workers}}) {
$count++;
}
my $count = scalar keys %{$self->{workers}};
my $need = $self->{max_workers} - $count;
return if $need <= 0;
@ -289,11 +285,7 @@ sub setup {
if ($restart && $self->{max_workers}) {
if (my $wpids = $ENV{PVE_DAEMON_WORKER_PIDS}) {
foreach my $pid (split(':', $wpids)) {
if ($pid =~ m/^(\d+)$/) {
$self->{old_workers}->{$1} = 1;
}
}
$self->{old_workers}->{$_} = 1 foreach (split(':', $wpids));
}
}
@ -503,8 +495,7 @@ sub restart_daemon {
}
if ($self->{max_workers}) {
my @workers = keys %{$self->{workers}};
push @workers, keys %{$self->{old_workers}};
my @workers = keys %{$self->{workers}}, keys %{$self->{old_workers}};
$ENV{PVE_DAEMON_WORKER_PIDS} = join(':', @workers);
}