Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Fix panics in the mtcp-client
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CryptoCopter authored and oxzi committed May 21, 2021
1 parent 3c47d4a commit fca8607
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/cla/mtcp/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019 Markus Sommer
// SPDX-FileCopyrightText: 2019, 2021 Markus Sommer
// SPDX-FileCopyrightText: 2019, 2020, 2021 Alvar Penning
//
// SPDX-License-Identifier: GPL-3.0-or-later
Expand Down Expand Up @@ -112,11 +112,12 @@ func (client *MTCPClient) handler() {

func (client *MTCPClient) Send(bndl bpv7.Bundle) (err error) {
defer func() {
if r := recover(); r != nil && err == nil {
if r := recover(); r != nil {
err = fmt.Errorf("MTCPClient.Send: %v", r)
}
}()

// In case of an error, report our failure upstream
defer func() {
if err != nil {
client.reportChan <- cla.NewConvergencePeerDisappeared(client, client.GetPeerEndpointID())
}
Expand Down

0 comments on commit fca8607

Please sign in to comment.