Improved setnonblocking() to set the flag on or off instead of just on.
This commit is contained in:
parent
65db384358
commit
0f53b154a3
@ -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)");
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user