From 7ec4fd6ab6509f46eca4f8e699d10ad40ebb286a Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 14 Dec 2023 18:26:04 +0000 Subject: [PATCH] comment on the timeout check --- server/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 365a17b..9f0ebea 100644 --- a/server/server.go +++ b/server/server.go @@ -127,9 +127,11 @@ func (s *Server) handleSubscribe(peer *peer.Peer) { for { action, err := readAction(peer, time.Millisecond*100) if err != nil { + // if the error is a timeout, it means the peer hasn't sent an action indicating it wishes to do something so sleep + // for a little bit to allow for other actions to happen on the connection var neterr net.Error if errors.As(err, &neterr) && neterr.Timeout() { - time.Sleep(time.Second) + time.Sleep(time.Millisecond * 500) continue } -- 2.51.2