Add timeout to client when server never creates FIFO.
If the server never creates the named pipe, then this loop originally hung forever. The count it now waits for is arbitrary, and probably could be smaller, since the current implementation of the server creates the pipe within 3-6 seconds under normal conditions.
This commit is contained in:
parent
975cceeaab
commit
90e6da323e
1 changed files with 10 additions and 1 deletions
|
@ -29,7 +29,16 @@ sub BeancountQuerySubmit($;$) {
|
|||
$BEANCOUNT_QUERY{question} = $question;
|
||||
$BEANCOUNT_QUERY{format} = $format if defined $format;
|
||||
(tied %BEANCOUNT_QUERY)->shunlock;
|
||||
while (not defined $BEANCOUNT_QUERY{fifoName}) { sleep 1; }
|
||||
my $cnt = 0;
|
||||
while (not defined $BEANCOUNT_QUERY{fifoName}) {
|
||||
sleep 1;
|
||||
if ($cnt++ >= (5 * 60)) {
|
||||
(tied %BEANCOUNT_QUERY)->shlock;
|
||||
$BEANCOUNT_QUERY{question} = $BEANCOUNT_QUERY{format} = undef;
|
||||
(tied %BEANCOUNT_QUERY)->shunlock;
|
||||
die "Unable to initiate query to beancount server\n";
|
||||
}
|
||||
}
|
||||
unless (-p $BEANCOUNT_QUERY{fifoName}) {
|
||||
(tied %BEANCOUNT_QUERY)->shlock;
|
||||
$BEANCOUNT_QUERY{question} = $BEANCOUNT_QUERY{format} = undef;
|
||||
|
|
Loading…
Reference in a new issue