Add context to upstreamConn.runUntilRegistered

This commit is contained in:
Simon Ser 2022-02-08 16:37:31 +01:00
parent 66a83e6345
commit 375ac53f74
2 changed files with 4 additions and 4 deletions

View File

@ -1955,14 +1955,14 @@ func (uc *upstreamConn) ReadMessage() (*irc.Message, error) {
return msg, nil
}
func (uc *upstreamConn) runUntilRegistered() error {
func (uc *upstreamConn) runUntilRegistered(ctx context.Context) error {
for !uc.registered {
msg, err := uc.ReadMessage()
if err != nil {
return fmt.Errorf("failed to read message: %v", err)
}
if err := uc.handleMessage(context.TODO(), msg); err != nil {
if err := uc.handleMessage(ctx, msg); err != nil {
if _, ok := err.(registrationError); ok {
return err
} else {
@ -1977,7 +1977,7 @@ func (uc *upstreamConn) runUntilRegistered() error {
if err != nil {
uc.logger.Printf("failed to parse connect command %q: %v", command, err)
} else {
uc.SendMessage(context.TODO(), m)
uc.SendMessage(ctx, m)
}
}

View File

@ -221,7 +221,7 @@ func (net *network) run() {
}
uc.register()
if err := uc.runUntilRegistered(); err != nil {
if err := uc.runUntilRegistered(context.TODO()); err != nil {
text := err.Error()
temp := true
if regErr, ok := err.(registrationError); ok {