Skip to content

Commit

Permalink
Stop logging an error whenever an RPC/P2P connection is canceled (#1562)
Browse files Browse the repository at this point in the history
* Don't log error when connectionLoop is canceled

* Print new line after Exiting...

* Add stacktrace to the unknown error from connectionLoops
  • Loading branch information
elichai authored Mar 1, 2021
1 parent 1f69f9e commit 103edf9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"net"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -62,7 +64,17 @@ func (c *gRPCConnection) Start(router *router.Router) {
spawn("gRPCConnection.Start-connectionLoops", func() {
err := c.connectionLoops()
if err != nil {
log.Errorf("error from connectionLoops for %s: %s", c.address, err)
status, isStatus := status.FromError(err)
if isStatus {
switch status.Code() {
case codes.Canceled:
log.Debugf("connectionLoop canceled connection for %s: %s", c.address, err)
default:
log.Errorf("status error from connectionLoops for %s: %s", c.address, err)
}
} else {
log.Errorf("unknown error from connectionLoops for %s: %+v", c.address, err)
}
}
})
}
Expand Down
3 changes: 1 addition & 2 deletions util/panics/panics.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ func exit(log *logger.Logger, reason string, currentThreadStackTrace []byte, gor
fmt.Fprintln(os.Stderr, "Couldn't exit gracefully.")
case <-exitHandlerDone:
}
fmt.Print("Exiting...")
fmt.Println("Exiting...")
os.Exit(1)
fmt.Print("After os.Exit(1)")
}

func handleSpawnedFunction(log *logger.Logger, stackTrace []byte, spawnedFunctionName string, spawnedFunction func()) {
Expand Down

0 comments on commit 103edf9

Please sign in to comment.