From 54dafa76c2ea2e3bc2ed283a211ccd00d25296ee Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Thu, 15 Dec 2022 14:22:37 -0800 Subject: [PATCH] Prevent lisafs socket communicator from returning io.EOF when server exits. This is consistent with what our p9 package does. See pkg/p9/client.go:sendRecvLegacySyscallErr(). This is also consistent with what lisafs channel communicator does. We log the actual error that caused the RPC to fail and map all transport errors to EIO. Returning io.EOF to the client may cause the sentry to panic if it tries to convert it into a syscall error in kernel.ExtractErrno(). PiperOrigin-RevId: 495696116 --- pkg/lisafs/channel.go | 2 +- pkg/lisafs/sock.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/lisafs/channel.go b/pkg/lisafs/channel.go index 2efe4b1a5..383b7ae04 100644 --- a/pkg/lisafs/channel.go +++ b/pkg/lisafs/channel.go @@ -74,7 +74,7 @@ func (ch *channel) SndRcvMessage(m MID, payloadLen uint32, wantFDs uint8) (MID, // This channel is now unusable. ch.dead = true // Map the transport errors to EIO, but also log the real error. - log.Warningf("lisafs.sndRcvMessage: flipcall.Endpoint.SendRecv: %v", err) + log.Warningf("channel.SndRcvMessage: flipcall.Endpoint.SendRecv failed: %v", err) return 0, 0, unix.EIO } diff --git a/pkg/lisafs/sock.go b/pkg/lisafs/sock.go index 8f554f9ed..aa50e9a02 100644 --- a/pkg/lisafs/sock.go +++ b/pkg/lisafs/sock.go @@ -83,11 +83,18 @@ func (s *sockCommunicator) PayloadBuf(size uint32) []byte { // SndRcvMessage implements Communicator.SndRcvMessage. func (s *sockCommunicator) SndRcvMessage(m MID, payloadLen uint32, wantFDs uint8) (MID, uint32, error) { + // Map the transport errors to EIO, but also log the real error. if err := s.sndPrepopulatedMsg(m, payloadLen, nil); err != nil { - return 0, 0, err + log.Warningf("socketCommunicator.SndRcvMessage: sndPrepopulatedMsg failed: %v", err) + return 0, 0, unix.EIO } - return s.rcvMsg(wantFDs) + respM, respPayloadLen, err := s.rcvMsg(wantFDs) + if err != nil { + log.Warningf("socketCommunicator.SndRcvMessage: rcvMsg failed: %v", err) + return 0, 0, unix.EIO + } + return respM, respPayloadLen, nil } // String implements fmt.Stringer.String.