]> xenbits.xensource.com Git - qemu-xen-4.0-testing.git/commitdiff
Do not disturb old fd flags (eg O_APPEND) when setting nonblock.
authorIan Jackson <iwj@mariner.uk.xensource.com>
Fri, 18 Jul 2008 13:28:52 +0000 (14:28 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 18 Jul 2008 13:36:56 +0000 (14:36 +0100)
socket_set_nonblock should not unconditionally call
fcntl(,F_SETFL,O_NONBLOCK) because that would clear other flags which
might be intentionally set on the fd.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
vl.c

diff --git a/vl.c b/vl.c
index c428c7e8c694fb397d6c3952918542bc2a69a022..0fb9c176dcd13359cd7f3a7d1320c84a09f93342 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2005,7 +2005,9 @@ static inline int send_all(int fd, const uint8_t *buf, int len1)
 
 void socket_set_nonblock(int fd)
 {
-    fcntl(fd, F_SETFL, O_NONBLOCK);
+    int f;
+    f = fcntl(fd, F_GETFL);
+    fcntl(fd, F_SETFL, f | O_NONBLOCK);
 }
 #endif /* !_WIN32 */