]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Use AnyEvent instead of signals in varnishcount.pl as well, since it seems signals...
[remoteglot] / remoteglot.pl
index 4e6edc68308f3524b252c765d61394126107f6cc..8cfb0be553049e74ba03fef87597a76bc02838b7 100755 (executable)
@@ -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} = {