librelist archives

« back to archive

[PATCH] use mask to get SOCK_STREAM arg from socket syscall

[PATCH] use mask to get SOCK_STREAM arg from socket syscall

From:
Eric Wong
Date:
2013-07-24 @ 09:06
Linux may OR SOCK_CLOEXEC and SOCK_NONBLOCK, so we must mask
those flags out to match SOCK_STREAM.
---
 nodelay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nodelay.c b/nodelay.c
index 265b0d6..afbb30e 100644
--- a/nodelay.c
+++ b/nodelay.c
@@ -55,7 +55,7 @@ int socket(int domain, int type, int protocol)
 
 	if (fd >= 0 &&
 	    protocol == IPPROTO_TCP &&
-	    type == SOCK_STREAM &&
+	    (type & SOCK_STREAM) == SOCK_STREAM &&
 	    domain == PF_INET) {
 		int orig_errno = errno;
 		int optval = nodelay_value;
-- 
Eric Wong