Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
linux: use ioctl(FIONBIO) to set O_NONBLOCK, saves a syscall
  • Loading branch information
bnoordhuis committed Oct 28, 2011
1 parent e4d6509 commit ed2b5e6
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/unix/core.c
Expand Up @@ -38,18 +38,22 @@
#include <limits.h> /* PATH_MAX */
#include <sys/uio.h> /* writev */

#ifdef __linux__
# include <sys/ioctl.h>
#endif

#ifdef __sun
# include <sys/types.h>
# include <sys/wait.h>
#endif

#if defined(__APPLE__)
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
#ifdef __APPLE__
# include <mach-o/dyld.h> /* _NSGetExecutablePath */
#endif

#if defined(__FreeBSD__)
#include <sys/sysctl.h>
#include <sys/wait.h>
#ifdef __FreeBSD__
# include <sys/sysctl.h>
# include <sys/wait.h>
#endif

static uv_loop_t default_loop_struct;
Expand Down Expand Up @@ -734,6 +738,9 @@ int uv__close(int fd) {


int uv__nonblock(int fd, int set) {
#if FIONBIO
return ioctl(fd, FIONBIO, &set);
#else
int flags;

if ((flags = fcntl(fd, F_GETFL)) == -1) {
Expand All @@ -751,6 +758,7 @@ int uv__nonblock(int fd, int set) {
}

return 0;
#endif
}


Expand Down

0 comments on commit ed2b5e6

Please sign in to comment.