Skip to content

Commit

Permalink
handle EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
raspi committed Jul 22, 2022
1 parent 65950fa commit aaffb4f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
error2 "github.com/raspi/jumiks/pkg/server/error"
"github.com/raspi/jumiks/pkg/server/header"
"github.com/raspi/jumiks/pkg/server/internal/serverclient"
"io"
"net"
"sync"
"syscall"
Expand Down Expand Up @@ -156,16 +157,21 @@ func (s *Server) Listen() {
// Send the buffer to client
wb, err := client.Write(msg)
if err != nil {
if errors.Is(err, syscall.EPIPE) {
client.Close()
if errors.Is(err, io.EOF) {
_ = client.Close()
delete(s.clients, clientId)
continue
} else if errors.Is(err, syscall.EPIPE) {
_ = client.Close()
delete(s.clients, clientId)
continue
} else if errors.Is(err, net.ErrClosed) {
client.Close()
_ = client.Close()
delete(s.clients, clientId)
continue
}

// Shouldn't happen
panic(err)
}

Expand Down

0 comments on commit aaffb4f

Please sign in to comment.