Abandon client question on timeout before die()'ing.

The server would lock up in cases where a client left a question
pending and die()'d due to this timeout.  So, before die()'ing, clear
the question.
This commit is contained in:
Bradley M. Kuhn 2021-01-06 11:04:04 -08:00
parent 10d809c180
commit 20ac3c5ef7
No known key found for this signature in database
GPG key ID: F15E8BD6D05E26B3

View file

@ -35,7 +35,12 @@ sub BeancountQuerySubmit($;$$) {
my $cnt = 0;
while (not defined $BEANCOUNT_QUERY{fifoName}) {
sleep 1;
die "Unable to initiate query to beancount server\n" if ($cnt++ >= (5 * 60));
if ($cnt++ >= (5 * 60)) {
(tied %BEANCOUNT_QUERY)->shlock;
$BEANCOUNT_QUERY{question} = undef;
(tied %BEANCOUNT_QUERY)->shunlock;
die "Unable to initiate query to beancount server\n" ;
}
}
unless (-p $BEANCOUNT_QUERY{fifoName}) {
(tied %BEANCOUNT_QUERY)->shlock;