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

irc: don't retry Connect() while stopped #1

Merged
merged 2 commits into from
Nov 7, 2023
Merged
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
18 changes: 14 additions & 4 deletions internal/irc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"github.com/sasha-s/go-deadlock"
)

var (
clientManuallyDisconnected = retry.Unrecoverable(errors.New("IRC client was manually disconnected"))
)

type channelHealth struct {
m deadlock.RWMutex

Expand Down Expand Up @@ -219,11 +223,17 @@ func (h *Handler) Run() error {
func() error {
h.log.Debug().Msgf("connect attempt %d", connectAttempts)

if err := h.client.Connect(); err != nil {
if err.Error() != "client has called Quit()" {
h.log.Error().Err(err).Msg("client encountered connection error")
}
// #1239: don't retry if the user manually disconnected with Stop()
h.m.RLock()
manuallyDisconnected := h.manuallyDisconnected
h.m.RUnlock()

if manuallyDisconnected {
return clientManuallyDisconnected
}

if err := h.client.Connect(); err != nil {
h.log.Error().Err(err).Msg("client encountered connection error")
connectAttempts++
return err
}
Expand Down