mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
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:
parent
1f69f9eed9
commit
103edf97d0
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user