Skip to content

Commit

Permalink
Make sure -sync commands are not stalled on disconnection
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gahr committed May 10, 2017
1 parent 75ee8d0 commit bec8b41
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion retcl.tm
Original file line number Diff line number Diff line change
Expand Up @@ -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}} {
Expand Down Expand Up @@ -250,7 +254,7 @@ oo::class create retcl {
return {}
}

vwait [self namespace]::resultsCache
vwait [self namespace]::activity

if {![my connected]} {
my Error {Disconnected}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bec8b41

Please sign in to comment.