Skip to content

Commit

Permalink
Small bugfix in connection monitor
Browse files Browse the repository at this point in the history
The connection monitor is a thread we spawn for each RPC; it's job is to
monitor the connection and close the RPC if the entire connection is closed. In
order to prevent memory leaks, the thread also terminates when the RPC is
closed independent of the connection. However, we were waiting for termination
of the _outbound_ thread to determine if the RPC is closed; it's better to wait
for termination of the _inbound_ thread, because the outbound thread is
terminated when the client sends its final message, but at that point we might
still be waiting on further messages from the server.

This doesn't matter too much, but becomes important in the next commit.
  • Loading branch information
edsko committed Jan 17, 2025
1 parent b70d6b2 commit be0cf48
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion grapesy/src/Network/GRPC/Client/Call.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ startRPC conn _ callParams = do
_ <- forkLabelled "grapesy:monitorConnection" $ do
status <- atomically $ do
(Left <$> Thread.waitForNormalOrAbnormalThreadTermination
(Session.channelOutbound channel))
(Session.channelInbound channel))
`orElse`
(Right <$> readTMVar connClosed)
case status of
Expand Down

0 comments on commit be0cf48

Please sign in to comment.