From 20ac3c5ef703c8fd929ed0b7021eeeffcefad437 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 6 Jan 2021 11:04:04 -0800 Subject: [PATCH] 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. --- bean-query-daemon-lib.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bean-query-daemon-lib.pl b/bean-query-daemon-lib.pl index 513ff3e..49be715 100644 --- a/bean-query-daemon-lib.pl +++ b/bean-query-daemon-lib.pl @@ -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;