From bec8b41146df1051824616e6fe86db886e5d018f Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Wed, 10 May 2017 14:06:48 +0000 Subject: [PATCH] Make sure -sync commands are not stalled on disconnection This introduces a new variable `activity` which is set everytime a readEvent occurs. A read event might be cause by a disconnection, in which case resultsCache is not changed and a synchronous client would otherwise stall forever while waiting to retrieve a result. --- retcl.tm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retcl.tm b/retcl.tm index 280ec65..2add7b7 100644 --- a/retcl.tm +++ b/retcl.tm @@ -97,6 +97,10 @@ oo::class create retcl { variable pipeline variable isPipelined + ## + # Simple sentinel that's set whenever there's activity + variable activity + ## # Constructor -- connect to a Retcl server. constructor {{host 127.0.0.1} {port 6379}} { @@ -250,7 +254,7 @@ oo::class create retcl { return {} } - vwait [self namespace]::resultsCache + vwait [self namespace]::activity if {![my connected]} { my Error {Disconnected} @@ -407,6 +411,7 @@ oo::class create retcl { ## # Handle a read event from the socket. method readEvent {} { + set activity 1 if {[chan eof $sock]} { my disconnect return