]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Reduce the number of Postgres transactions we start.
[remoteglot] / remoteglot.pl
index 7097306fecfd3795c407392164fcda012c5de1ed..35fe887382eaabb2cc0e0dd7be9a8809c9bf4eea 100755 (executable)
@@ -67,7 +67,7 @@ select(TBLOG);
 $| = 1;
 
 select(STDOUT);
-umask 0027;  # analysis.json should not be served to users.
+umask 0022;  # analysis.json should not be served to users.
 
 # open the chess engine
 my $engine = open_engine($remoteglotconf::engine_cmdline, 'E1', sub { handle_uci(@_, 1); });
@@ -533,7 +533,7 @@ sub prettyprint_pv_no_cache {
 sub prettyprint_pv {
        my ($pos, @pvs) = @_;
 
-       my $cachekey = $pos->{'fen'} . join('', @pvs);
+       my $cachekey = $pos->fen() . join('', @pvs);
        if (exists($pos->{'prettyprint_cache'}{$cachekey})) {
                return @{$pos->{'prettyprint_cache'}{$cachekey}};
        } else {
@@ -901,6 +901,7 @@ sub output_json {
        if (!$historic_json_only && exists($pos_calculating->{'history'})) {
                my %score_history = ();
 
+               local $dbh->{AutoCommit} = 0;
                my $q = $dbh->prepare('SELECT * FROM scores WHERE id=?');
                my $pos = Position->start_pos('white', 'black');
                my $halfmove_num = 0;
@@ -917,6 +918,7 @@ sub output_json {
                        ($pos) = $pos->make_pretty_move($move);
                }
                $q->finish;
+               $dbh->commit;
 
                # If at any point we are missing 10 consecutive moves,
                # truncate the history there. This is so we don't get into