Get rid of io.EOF errors in logs
Closes: https://todo.sr.ht/~emersion/soju/150
This commit is contained in:
parent
0cd18a78db
commit
aa407a46e6
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@ -434,7 +435,7 @@ func (dc *downstreamConn) unmarshalText(uc *upstreamConn, text string) string {
|
||||
func (dc *downstreamConn) readMessages(ch chan<- event) error {
|
||||
for {
|
||||
msg, err := dc.ReadMessage()
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("failed to read IRC command: %v", err)
|
||||
@ -1354,7 +1355,7 @@ func (dc *downstreamConn) runUntilRegistered() error {
|
||||
for !dc.registered {
|
||||
msg, err := dc.ReadMessage()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read IRC command: %v", err)
|
||||
return fmt.Errorf("failed to read IRC command: %w", err)
|
||||
}
|
||||
|
||||
err = dc.handleMessage(msg)
|
||||
|
@ -177,7 +177,9 @@ func (s *Server) handle(ic ircConn) {
|
||||
id := atomic.AddUint64(&lastDownstreamID, 1)
|
||||
dc := newDownstreamConn(s, ic, id)
|
||||
if err := dc.runUntilRegistered(); err != nil {
|
||||
if !errors.Is(err, io.EOF) {
|
||||
dc.logger.Print(err)
|
||||
}
|
||||
} else {
|
||||
dc.user.events <- eventDownstreamConnected{dc}
|
||||
if err := dc.readMessages(dc.user.events); err != nil {
|
||||
|
@ -1725,7 +1725,7 @@ func (uc *upstreamConn) runUntilRegistered() error {
|
||||
func (uc *upstreamConn) readMessages(ch chan<- event) error {
|
||||
for {
|
||||
msg, err := uc.ReadMessage()
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("failed to read IRC command: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user