Stop logging an error whenever an RPC/P2P connection is canceled (#1562)

* Don't log error when connectionLoop is canceled

* Print new line after Exiting...

* Add stacktrace to the unknown error from connectionLoops
This commit is contained in:
Elichai Turkel 2021-03-01 14:37:42 +02:00 committed by GitHub
parent 1f69f9eed9
commit 103edf97d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -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"
@ -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)
}
}
})
}

View File

@ -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()) {