From 1e627b833e3a96eb91f8616d73488b9fb689f36e Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Fri, 3 Jun 2022 12:33:03 -0700 Subject: [PATCH] Skip LRPCChannel send(), done(), and close() if already closed --- client/web/lrpc.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/web/lrpc.rb b/client/web/lrpc.rb index 8e8762b..e6786f1 100644 --- a/client/web/lrpc.rb +++ b/client/web/lrpc.rb @@ -100,6 +100,7 @@ class LRPCChannel # Set self variables @client = client @id = id + @closed = false # Set function variables to no-ops @onMessage = proc {|fn|} @onClose = proc {} @@ -112,6 +113,7 @@ class LRPCChannel # send sends a value on the channel. This should not # be called by the consumer of the channel. def send(val) + return if @closed fn = @onMessage fn(val) end @@ -119,6 +121,7 @@ class LRPCChannel # done cancels the context corresponding to the channel # on the server side and closes the channel. def done() + return if @closed @client.callMethod("lrpc", "ChannelDone", @id) self.close() @client._callMap.delete(@id) @@ -144,5 +147,6 @@ class LRPCChannel def close() fn = @onClose fn() + @closed = true end end \ No newline at end of file