From aaffb4fc78b98504248c177f23b539880cb0a70c Mon Sep 17 00:00:00 2001 From: raspi Date: Fri, 22 Jul 2022 17:23:24 +0300 Subject: [PATCH] handle EOF --- pkg/server/server.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index e71a236..c51113a 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -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" @@ -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) }