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

ARCO-105: When restarting, cancel writer, reader and disconnect so th… #30

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 10 additions & 10 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,7 @@ func (p *Peer) startReadHandler(ctx context.Context) {
p.logger.Error("Retrying to read failed", slog.String(errKey, err.Error()))

// stop all read and write handlers
p.cancelWriteHandler()
p.cancelReadHandler()

p.disconnectLock()
p.Restart()

return
}
Expand Down Expand Up @@ -719,10 +716,7 @@ func (p *Peer) startWriteChannelHandler(ctx context.Context, instance int) {
p.logger.Error("Failed retrying to write message", slog.Int("instance", instance), slog.String(errKey, err.Error()))

// stop all read and write handlers
p.cancelWriteHandler()
p.cancelReadHandler()

p.disconnectLock()
p.Restart()

return
}
Expand Down Expand Up @@ -856,9 +850,15 @@ func (p *Peer) IsHealthy() bool {
}

func (p *Peer) Restart() {
p.Shutdown()
if p.cancelWriteHandler != nil {
p.cancelWriteHandler()
}

p.start()
if p.cancelReadHandler != nil {
p.cancelReadHandler()
}

p.disconnectLock()
}

func (p *Peer) Shutdown() {
Expand Down
Loading