Skip to content

Commit

Permalink
Fix error message when one side of unix sockets is closed for writing.
Browse files Browse the repository at this point in the history
When one end of the connection is closed, write for unix sockets returns
connection refused error in Linux. Make the gVisor behavior the same as Linux.

PiperOrigin-RevId: 631949102
  • Loading branch information
nybidari authored and gvisor-bot committed May 8, 2024
1 parent a3b19da commit bc748d4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/sentry/socket/unix/transport/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (q *queue) Enqueue(ctx context.Context, data [][]byte, c ControlMessages, f

if q.closed.RacyLoad() {
q.mu.Unlock()
return 0, false, syserr.ErrClosedForSend
return 0, false, syserr.ErrConnectionRefused
}

for _, d := range data {
Expand Down
4 changes: 0 additions & 4 deletions test/syscalls/linux/socket_unix_dgram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ namespace testing {
namespace {

TEST_P(DgramUnixSocketPairTest, WriteOneSideClosed) {
// FIXME(b/35925052): gVisor datagram sockets return EPIPE instead of
// ECONNREFUSED.
SKIP_IF(IsRunningOnGvisor());

auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());
ASSERT_THAT(close(sockets->release_first_fd()), SyscallSucceeds());
constexpr char kStr[] = "abc";
Expand Down

0 comments on commit bc748d4

Please sign in to comment.