Commit Graph

1794 Commits

Author SHA1 Message Date
Ben Noordhuis
2b04bc7a74 doc: add note about -D_GNU_SOURCE 2012-09-13 14:13:21 +02:00
Saúl Ibarra Corretgé
b7047d6701 unix: remove __read_mostly macro
It creates trouble with llvm-gcc on OS X.
2012-09-13 01:47:34 +02:00
Fedor Indutny
f8e7513a06 darwin: use FSEvents to watch directory changes 2012-09-12 23:38:57 +02:00
Shigeki Ohtsu
57e6113683 unix: support missing api on NetBSD 2012-09-11 17:23:43 +02:00
Ben Noordhuis
4f5c8da191 unix: reimplement accept() EMFILE trick
Implement a best effort approach to mitigating accept() EMFILE errors.

We have a spare file descriptor stashed away that we close to get below
the EMFILE limit. Next, we accept all pending connections and close them
immediately to signal the clients that we're overloaded - and we are, but
we still keep on trucking.

There is one caveat: it's not reliable in a multi-threaded environment.
The file descriptor limit is per process. Our party trick fails if another
thread opens a file or creates a socket in the time window between us
calling close() and accept().

Fixes #315.
2012-09-10 22:12:30 +02:00
Ben Noordhuis
86cb5203b6 unix: fix EMFILE busy loop
Don't spin in epoll_wait() / kevent() / port_getn() / etc. when we can't
accept() a new connection due to having reached the file descriptor limit.
Pass the error to the connection_cb and let the libuv user deal with it.
2012-09-10 21:47:32 +02:00
Bert Belder
27b11abcc0 unix: mark accept idle handle as internal 2012-09-08 17:52:57 +02:00
Ben Noordhuis
817b6c356b build: make gyp_uv understand '-f ninja' 2012-09-07 15:08:43 +02:00
Ben Noordhuis
3bbe8f9754 Merge branch 'v0.8' 2012-09-04 01:23:18 +02:00
Ben Noordhuis
b101a53e6e sunos: don't set TCP_KEEPALIVE
The system headers advertise the socket option but the actual syscall fails
with ENOPROTOOPT.

Fixes joyent/node#3937.
2012-09-04 01:20:33 +02:00
Bert Belder
032c041790 windows: use UV_HANDLE_READABLE and UV_HANDLE_WRITABLE
These flags supersede UV_HANDLE_EOF and UV_HANDLE_SHUTTING. This patch
also moves a lot of stream related state-checking code to stream.c.
2012-09-03 21:09:40 +02:00
Bert Belder
483043b0e5 windows: map WSAESHUTDOWN to UV_EPIPE 2012-09-03 17:16:21 +02:00
Bert Belder
0bbccbc31d windows: remove the UV_HANDLE_SHUT flag 2012-09-03 15:38:29 +02:00
Ben Noordhuis
ff0a93a04f unix: fix clang -Wlanguage-extension-token warnings 2012-09-01 00:27:57 +02:00
Bert Belder
5eb1d191cc Merge branch 'v0.8' 2012-08-30 17:26:02 +02:00
Bert Belder
24c062cc3e windows: fix memory corruption when closing shared server sockets 2012-08-30 17:25:32 +02:00
Ben Noordhuis
a75e10504f freebsd: fix build breakage introduced in 3b69c0f 2012-08-29 22:27:27 +02:00
Shigeki Ohtsu
09faee40eb windows: fix environment_creation test
abc945bc04 fails environment_creation test
2012-08-29 04:31:25 +02:00
Bert Belder
abc945bc04 windows: make spawn with custom environment work again 2012-08-28 22:33:52 +02:00
Bert Belder
5c674b2889 windows: squelch some warnings related to int64 to int32 conversion 2012-08-28 22:33:52 +02:00
Bert Belder
162e57baa9 windows: map ERROR_DIRECTORY to UV_ENOENT 2012-08-28 21:49:54 +02:00
Bert Belder
621a4e36f7 test: add test for uv_is_active and uv_is_closing 2012-08-27 23:57:48 +02:00
Bert Belder
637be161b3 windows: make active and closing handle state independent 2012-08-27 23:56:35 +02:00
Ben Noordhuis
c77d08eb92 bench: add timed and non-timed udp pummel benchmarks 2012-08-25 22:37:18 +02:00
Ben Noordhuis
a3c6a485c6 Merge branch 'v0.8'
Conflicts:
	include/uv.h
2012-08-25 22:33:17 +02:00
Ben Noordhuis
ad7b48aeec unix: fix memory leak in udp.c
Some memory was leaked when the uv_udp_t handle was closed when there were
in-flight send requests with a heap allocated buffer list.

That doesn't happen much in practice. In the common case (writing < 5 buffers),
the buffer list is stored inside the uv_udp_send_t structure, not allocated on
the heap.
2012-08-25 22:28:52 +02:00
Shigeki Ohtsu
343be71cae windows: remove superfluous uv__handle_start
uv__handle_start was not needed in uv_signal_init
2012-08-25 07:00:21 +02:00
Bert Belder
d62b1ac382 windows: fix the MinGW build 2012-08-23 23:50:03 +02:00
Ben Noordhuis
e89cb907a2 unix: fix aliasing warnings in stream.c 2012-08-23 15:52:39 +02:00
Ben Noordhuis
b81e67a19c unix: fix aliasing warning in udp.c 2012-08-23 15:51:06 +02:00
Ben Noordhuis
0ac2fdc554 unix: map errno ESPIPE 2012-08-23 00:32:56 +02:00
Bert Belder
a787a16ac3 unix: fix uv_async_send not working with Sun Studio
uv_async_send would always return 1 when non-gcc compilers were used.
When uv_async_send returns 1 no attempt is made to make port_getn
return, so in this situation uv_async_send didn't wake up the event
loop.
2012-08-22 20:40:14 +02:00
Ben Noordhuis
120e2c1335 darwin: fix return value of uv_sem_init()
It should return 0 or -1, not the kernel status code.
2012-08-22 15:03:26 +02:00
Fedor Indutny
8969df6015 darwin: handle KERN_ABORTED in uv_sem_wait() 2012-08-22 15:01:39 +02:00
Ben Noordhuis
29eb460d0b linux: fix fscanf() -Wunused-result warning 2012-08-22 09:48:02 +02:00
Bert Belder
03bdfd08cc windows: lock tty output before updating the virtual window size 2012-08-22 01:06:05 +02:00
Bert Belder
564e7c765c windows: emit SIGWINCH when the console size changes 2012-08-22 00:43:55 +02:00
Ben Noordhuis
b12b6498d6 darwin, freebsd: use ioctl(FIOCLEX) and ioctl(FIONBIO)
Set the non-blocking and close-on-exec flags with ioctl() instead of fcntl(),
it's about 10-25% faster.

Stick with fcntl() on Solaris. ioctl(FIONBIO) works but is twice as slow as
fcntl(O_NONBLOCK). ioctl(FIOCLEX) doesn't raise an error but doesn't actually
work either.
2012-08-21 23:21:37 +02:00
Bert Belder
37173f8515 Merge branch 'v0.8' 2012-08-21 01:20:05 +02:00
Bert Belder
a7b83e0b98 windows: fix uninitialized memory access in uv_update_time()
uv_update_time does not overwrite the high 32 bits of uv_loop_t.time.
It merely increments it by one when the low 32 bits have wrapped. That
means that `time` needs to be initialized to zero before
uv_update_time() is called for the first time.
2012-08-21 01:17:52 +02:00
Ben Noordhuis
d90102e649 linux: don't retry syscall after ENOSYS
Don't try the pipe2() or socketpair(O_CLOEXEC) syscalls when a previous call to
uv__make_pipe() or uv__make_socketpair() call established that the kernel
doesn't support it. Speeds up pipe and socketpair creation on older kernels.
2012-08-21 01:03:59 +02:00
Ben Noordhuis
6545e9bda4 linux: tag no_accept4 __read_mostly 2012-08-21 01:03:59 +02:00
Ben Noordhuis
5f8185aba5 unix: add __read_mostly macro
Variables tagged with __read_mostly are put into a separate ELF section to
improve the cache locality of data that is read often but seldom written to.
2012-08-21 01:03:56 +02:00
Ben Noordhuis
3c526cb7e5 linux: fix uv__epoll_create() prototype 2012-08-21 00:27:55 +02:00
Fedor Indutny
5da380a5ca unix: use select() for specific fds on OS X
kqueue(2) on osx doesn't work (emits EINVAL error) with specific fds
(i.e. /dev/tty, /dev/null, etc). When given such descriptors - start
select(2) watcher thread that will emit io events.
2012-08-20 23:35:13 +02:00
Bert Belder
8073a2637f windows: uv_signal_stop should be infallible 2012-08-20 18:39:49 +02:00
Bert Belder
b0b5a08f56 windows: report UV_INVAL when an invalid signum is supplied 2012-08-20 18:39:49 +02:00
Bert Belder
328f29b06f windows: fix stupid uv_signal bugs 2012-08-20 18:39:48 +02:00
Ben Noordhuis
28ff1422e8 Merge branch 'v0.8'
Conflicts:
	src/fs-poll.c
2012-08-20 18:11:43 +02:00
Ben Noordhuis
012cbda719 unix, windows: fix memory corruption in fs-poll.c
uv_fs_poll_t has an embedded uv_timer_t handle that got closed at a time when
the memory of the encapsulating handle might already have been deallocated.

Solve that by moving the poller's state into a structure that is allocated on
the heap and can be freed independently.
2012-08-20 17:13:27 +02:00