From 110fcad2ecce39d6888448c19b08791ea193e7f9 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Mon, 4 Jun 2012 13:14:42 -0700 Subject: [PATCH] rsocket: Handle SHUT_RD/WR shutdown flags Sridhar Samudrala reported an error (EOPNOTSUPP) after calling select(). The issue is that rshutdown(SHUT_WR) was called before select(). As part of shutdown, rsockets switches the underlying fd from nonblocking to blocking to ensure that previously sent data has completed. shutdown(SHUT_WR) indicates that the socket should be kept open for receiving data. Delay handling the actual shutdown unless SHUT_RDWR is specified, or the socket is closed. Signed-off-by: Sean Hefty --- src/rsocket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rsocket.c b/src/rsocket.c index c1117970..8f20b4ab 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -1592,6 +1592,9 @@ int rshutdown(int socket, int how) struct rsocket *rs; int ret = 0; + if (how != SHUT_RDWR) + return 0; + rs = idm_at(&idm, socket); if (rs->fd_flags & O_NONBLOCK) rs_set_nonblocking(rs, 0); -- 2.45.2