Skip to contentSkip to conversation

Do not disturb old fd flags (eg O_APPEND) when setting nonblock.

PATCH Applied Ian Jackson 1 participant 1 message Jul 18, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 Do not disturb old fd flags (eg O_APPEND) when setting nonblock.

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.

---
 vl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
vl.c +3 -1
index c428c7e..0fb9c17 100644
@@ -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 */
 
Signature · 1 line
1.4.4.4