From 0546c4baa24d60280d2f08703b512c441ea28ed0 Mon Sep 17 00:00:00 2001 From: nohar Date: Thu, 14 Jun 2007 08:48:04 +0000 Subject: [PATCH] Set socket flags setting. --- src/connection.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/connection.c b/src/connection.c index 4eee6a8..711eace 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1423,7 +1423,15 @@ static int connection_timedout(connection_t *cn) static int socket_set_nonblock(int s) { - if (fcntl(s, F_SETFL, O_NONBLOCK) < 0) { + int flags; + + if ((flags = fcntl(s, F_GETFL, 0)) < 0) { + mylog(LOG_ERROR, "Cannot set socket %d to non blocking : %s", + s, strerror(errno)); + return 0; + } + + if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) { mylog(LOG_ERROR, "Cannot set socket %d to non blocking : %s", s, strerror(errno)); return 0;