diff mbox

net: fix accept4() flags not work

Message ID 1483872450-2706-1-git-send-email-cugyly@163.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

yuan linyu Jan. 8, 2017, 10:47 a.m. UTC
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

user input flags store to newsock which should be used.

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
 net/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller Jan. 9, 2017, 9:37 p.m. UTC | #1
From: yuan linyu <cugyly@163.com>
Date: Sun,  8 Jan 2017 18:47:30 +0800

> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> 
> user input flags store to newsock which should be used.
> 
> Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

It is the file flags of the parent listening socket that determines if
the accept() blocks or not.

The man page for accept() is clear about this:

	... and the socket is not marked as nonblocking

meaning the parent listening socket.

The "flags" argument of accept4() is purely for setting flags on
the accepted new child socket, it has no influence whatsoever
about the blocking of the accept() call or not.  That behavior
is determined in the context of the listening socket.
diff mbox

Patch

diff --git a/net/socket.c b/net/socket.c
index a8c2307..415f988 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1508,7 +1508,7 @@  SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
 	if (err)
 		goto out_fd;
 
-	err = sock->ops->accept(sock, newsock, sock->file->f_flags);
+	err = sock->ops->accept(sock, newsock, newsock->file->f_flags);
 	if (err < 0)
 		goto out_fd;