diff --git a/src/net.c b/src/net.c index c354c8b..665430b 100644 --- a/src/net.c +++ b/src/net.c @@ -337,7 +337,7 @@ set_tcp_options(int sock, int no_delay, int mss) /****************************************************************************/ int -setnonblocking(int fd) +setnonblocking(int fd, int nonblocking) { int flags, newflags; @@ -346,7 +346,10 @@ setnonblocking(int fd) perror("fcntl(F_GETFL)"); return -1; } - newflags = flags | (int) O_NONBLOCK; + if (nonblocking) + newflags = flags | (int) O_NONBLOCK; + else + newflags = flags & ~((int) O_NONBLOCK); if (newflags != flags) if (fcntl(fd, F_SETFL, newflags) < 0) { perror("fcntl(F_SETFL)"); diff --git a/src/net.h b/src/net.h index 81e45de..48e9275 100644 --- a/src/net.h +++ b/src/net.h @@ -18,7 +18,7 @@ int has_sendfile(void); int Nsendfile(int fromfd, int tofd, const char *buf, size_t count) /* __attribute__((hot)) */; int getsock_tcp_mss(int inSock); int set_tcp_options(int sock, int no_delay, int mss); -int setnonblocking(int fd); +int setnonblocking(int fd, int nonblocking); #define NET_SOFTERROR -1 #define NET_HARDERROR -2