-
Notifications
You must be signed in to change notification settings - Fork 14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks a lot!
However, after applying your suggest changes, an error will not be sent for recovered panics. But especially those errors might be very important.
Thus, I would suggest some kind of multiple stacked defers
.
defer client.mutex.Unlock()
, as beforerecover
and assign errors toerr
if err != nil {client.reportChan <- cla.NewConvergencePeerDisappeared(client, client.GetPeerEndpointID()) }
- another
recover
to catch panics due to an already closed channel.
Due to its stack nature, the defer
s needs to be applied in reverse.
I sketched this one here: https://play.golang.org/p/JWkgNRg84s7
Of course, this might not be the most beautiful solution but should cover all possibilities.
come to think of it, I believe that I originally included the
|
889e3f1
to
b9a9036
Compare
If the write to reportChan is deferred, and reportChang has already been closed, then the resulting panic won't be recovered by the deferred recover-function.
b9a9036
to
306a2ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's start with some history. The first deferred recover was introduced in early 2019 by fa14812 to mitigate a panic within go-codec, I guess. However, in the meantime the whole functional body of this method was changed completely.
I think you are totally right that one recover is enough.
The point about two recovers was that a panic from within the method's body could still be sent into the channel. However, I don't see any "panicable" code there anymore.
LGTM, thanks again!
As can be seen in recent issues and PRs (#39, #40, #41, #42, #43, #45), there is an issue in dtn7-go that results in a deadlock after some time, making it impossible to sent bundles. To be able to test and debug this issue, some more extensive tests are required. Thus, we developed a test infrastructure to simulate multiple virtual nodes using the [CORE emulator](https://github.com/coreemu/core). This tests environment is located in the [dtn7-playground](https://github.com/dtn7/dtn7-playground) repository. To be able to trigger these tests, this PR adds a workflow file, that uses the [repository_dispatch event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch) sent to the dtn7-playground repo.
* Workflow for extended tests As can be seen in recent issues and PRs (#39, #40, #41, #42, #43, #45), there is an issue in dtn7-go that results in a deadlock after some time, making it impossible to sent bundles. To be able to test and debug this issue, some more extensive tests are required. Thus, we developed a test infrastructure to simulate multiple virtual nodes using the [CORE emulator](https://github.com/coreemu/core). This tests environment is located in the [dtn7-playground](https://github.com/dtn7/dtn7-playground) repository. To be able to trigger these tests, this PR adds a workflow file, that uses the [repository_dispatch event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch) sent to the dtn7-playground repo. * Fix copyright header Co-authored-by: Artur Sterz <[email protected]>
If the write to reportChan is deferred, and reportChang has already been
closed, then the resulting panic won't be recovered by the deferred
recover-function.