forked from rabbitmq/amqp091-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connection: fix: reader go-routine is leaked on connection close
When a message was sent and it's response was received while the connection was closed or an error happened, the reader go-routine could get stuck and be leaked. The reader go routine tries to send a received message to the unbuffered c.rpc channel via the dispatch0() and dispatchN() methods. The call() method reads from the rpc channel. If an error happened while the dispatch method sends a message to the rpc channel, the call() method could terminate because it read an error from c.errors or because c.errors was closed. To prevent the scenario: - the reader go-routine now closes c.rpc when it terminates, - The call() method, reads from c.rpc until a message was received or it is closed. When c.rpc is closed, it reads an error from c.errors or wait until c.errors is closed. When it reads an error, it returns it. If it is closed it returns ErrClosed. This ensures that the messages is read from c.rpc before call() returns. It also ensures that when a message was received that it is processed. Previously it could happen that the message was silently ignored because c.errors returned an error or was closed. tests: add testcase to ensure reader routine terminates Add a testcase for the bug that the reader go-routine tries to send a message to the buffered rpc channel but call() terminated because it read an error from the errors chan or the errors chan was closed. It cause that reader routine gets stuck forever and does not terminate when the connection is closed. More information: rabbitmq#69. This testcase does not reproduce the issue reliably, but it is triggered in ~80% of executions. Bump GH actions versions Add step in GH actions to download goleak dependency
- Loading branch information
1 parent
6cac2fa
commit 3e2ea21
Showing
6 changed files
with
57 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module github.com/rabbitmq/amqp091-go | ||
|
||
go 1.16 | ||
|
||
require go.uber.org/goleak v1.1.12 |