From 2739cf46284f2786ad33b545d55b8178bc46f7de Mon Sep 17 00:00:00 2001
From: Bhasker Hariharan <bhaskerh@google.com>
Date: Thu, 22 Apr 2021 16:31:11 -0700
Subject: Fix AF_UNIX listen() w/ zero backlog.

In https://github.com/google/gvisor/commit/f075522849fa a check to increase zero
to a minimum backlog length was removed from sys_socket.go to bring it in parity
with linux and then in tcp/endpoint.go we bump backlog by 1. But this broke
calling listen on a AF_UNIX socket w/ a zero backlog as in linux it does allow 1
connection even with a zero backlog.

This was caught by a php runtime test socket_abstract_path.phpt.

PiperOrigin-RevId: 369974744
---
 pkg/sentry/socket/unix/transport/connectioned.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'pkg/sentry/socket/unix')

diff --git a/pkg/sentry/socket/unix/transport/connectioned.go b/pkg/sentry/socket/unix/transport/connectioned.go
index 408dfb08d..33f9aeb06 100644
--- a/pkg/sentry/socket/unix/transport/connectioned.go
+++ b/pkg/sentry/socket/unix/transport/connectioned.go
@@ -346,11 +346,11 @@ func (e *connectionedEndpoint) BidirectionalConnect(ctx context.Context, ce Conn
 
 		return nil
 	default:
-		// Busy; return ECONNREFUSED per spec.
+		// Busy; return EAGAIN per spec.
 		ne.Close(ctx)
 		e.Unlock()
 		ce.Unlock()
-		return syserr.ErrConnectionRefused
+		return syserr.ErrTryAgain
 	}
 }
 
-- 
cgit v1.2.3