Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix close log #1068

Merged
merged 2 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/servicedisc/autoconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package servicedisc

import (
"context"
"errors"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -81,7 +83,9 @@ func (a *autoconnector) Run(ctx context.Context) (err error) {
a.log.WithField("pk", pk).WithField("attempt", val).Debugln("Trying to add transport to public visor")
logger := a.log.WithField("pk", pk).WithField("type", string(network.STCPR))
if err = a.tryEstablishTransport(ctx, pk, logger); err != nil {
logger.WithError(err).Warnln("Failed to add transport to public visor")
if !errors.Is(err, io.ErrClosedPipe) {
logger.WithError(err).Warnln("Failed to add transport to public visor")
}
failedAddresses[pk]++
continue
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/transport/network/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net"
"strings"
"sync"

"github.com/skycoin/dmsg"
Expand Down Expand Up @@ -150,6 +151,12 @@ func (c *genericClient) acceptTransports(lis net.Listener) {
if errors.Is(err, io.EOF) {
continue // likely it's a dummy connection from service discovery
}

if c.isClosed() && (errors.Is(err, io.ErrClosedPipe) || strings.Contains(err.Error(), "use of closed network connection")) {
c.log.Info("Cleanly stopped serving.")
return
}

c.log.Warnf("failed to accept incoming connection: %v", err)
if !handshake.IsHandshakeError(err) {
c.log.Warnf("stopped serving")
Expand Down