X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=8cfb0be553049e74ba03fef87597a76bc02838b7;hp=4e6edc68308f3524b252c765d61394126107f6cc;hb=d5d7dc50fe8f44711a2e4d52563ff40db029e819;hpb=25b4c5b0537cb335c09c7b1bf4e765c5aa6cf412 diff --git a/remoteglot.pl b/remoteglot.pl index 4e6edc6..8cfb0be 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -28,8 +28,8 @@ use warnings; no warnings qw(once); # Program starts here -$SIG{ALRM} = sub { output(); }; my $latest_update = undef; +my $output_timer = undef; my $http_timer = undef; my $tb_retry_timer = undef; my %tb_cache = (); @@ -266,7 +266,8 @@ sub handle_pgn { my $moves = $pgn->moves; my @uci_moves = (); for my $move (@$moves) { - my ($pos, $uci_move) = $pos->make_pretty_move($move); + my $uci_move; + ($pos, $uci_move) = $pos->make_pretty_move($move); push @uci_moves, $uci_move; } $pos->{'history'} = \@uci_moves; @@ -477,7 +478,8 @@ sub output { # Don't update too often. my $age = Time::HiRes::tv_interval($latest_update); if ($age < $remoteglotconf::update_max_interval) { - Time::HiRes::alarm($remoteglotconf::update_max_interval + 0.01 - $age); + my $wait = $remoteglotconf::update_max_interval + 0.01 - $age; + $output_timer = AnyEvent->timer(after => $wait, cb => \&output); return; } @@ -930,7 +932,8 @@ sub handle_tb_lookup_return { my $moves = $pgn->moves; my @uci_moves = (); for my $move (@$moves) { - my ($pvpos, $uci_move) = $pvpos->make_pretty_move($move); + my $uci_move; + ($pvpos, $uci_move) = $pvpos->make_pretty_move($move); push @uci_moves, $uci_move; } $tb_cache{$fen} = {