Commit Graph

1693 Commits

Author SHA1 Message Date
Bert Belder
35c4858231 Remove c-ares tests and benchmarks 2012-08-07 01:03:51 +02:00
Bert Belder
3a8bb3b2b1 Use uv_inet_ntop/uv_inet_pton, instead of the c-ares implementations 2012-08-07 01:03:51 +02:00
Bert Belder
32f93e14cb Add libuv-ified versions of inet_pton and inet_ntop 2012-08-07 01:03:47 +02:00
Bert Belder
3b46285ff8 windows: remove libeio mentions from Makefile
Libeio is not used on Windows.
2012-08-07 01:03:38 +02:00
Bert Belder
32da23988b Merge branch 'v0.8'
Conflicts:
	src/unix/sunos.c
2012-08-05 23:51:04 +02:00
Bert Belder
dfb6be0e07 windows: map WSANO_DATA to UV_ENOENT
This improves uv_getaddrinfo error reporting.
2012-08-03 17:37:22 +02:00
Ben Noordhuis
9f7cdb20aa unix: add relaxed accept() setting
Mitigates unfair scheduling in multi-process setups that share a single listen
socket across multiple processes.
2012-08-02 15:58:55 +02:00
Bert Belder
6209fe51f0 windows: invalid stdio handles should be INVALID_HANDLE_VALUE and not NULL 2012-08-01 01:09:07 +02:00
Bert Belder
109e176ae2 windows: only allow opening directories for reading
This is closer to the Posix model.
2012-08-01 00:31:31 +02:00
Bert Belder
69c2ef8acc windows: initialize uv_fs_t.path to NULL
This shouldn't be necessary, but node v0.8 relies on it.
2012-07-31 21:08:26 +02:00
Bert Belder
9d71d1cab5 windows/uv_spawn: ignore errors when duplicating fd 0-2 fails
Hopefully this fixes joyent/node#3779.
2012-07-31 19:38:43 +02:00
Bert Belder
ed2bc23346 windows: fix the MinGW build 2012-07-31 17:24:46 +02:00
Bert Belder
7f6b86c687 windows: improve uv_fs_unlink
* It's now more efficient, the file is not opened twice.
* It no longer allows deletion of non-symlink directory reparse points.
2012-07-31 17:24:45 +02:00
Bert Belder
7edc29a414 windows: fix regression in uv_fs_link
Old and new path were accidentally reversed.
2012-07-31 17:24:45 +02:00
Ben Noordhuis
d192a317aa sunos: workaround OS bug to prevent fs.watch() from spinning
This is a back-port of commit cfb06db from the master branch.

Fixes joyent/node#3768.
2012-07-31 15:07:40 +00:00
Bryan Cantrill
cfb06db5e5 sunos: workaround OS bug to prevent fs.watch() from spinning
Fixes joyent/node#3768.
2012-07-31 16:56:00 +02:00
Alan Gutierrez
8f66bfcee0 doc: add 'Intro to libuv' link to README
Add a link to 'An Introduction to libuv' to the documentation section of
README.md. Format the section as a bullet list.
2012-07-31 01:31:16 +02:00
Ben Noordhuis
4168855da5 include: move ssize_t workaround to uv-win.h 2012-07-31 00:05:03 +02:00
Bert Belder
514265ec6e windows: fix memory leaks in fs
Also clean up the code in various ways.
2012-07-31 00:04:48 +02:00
Ben Noordhuis
4eccb2ee52 include: move ssize_t workaround to uv-win.h 2012-07-30 14:26:50 +02:00
Bert Belder
1d5eb91474 Avoid compiler warning 2012-07-30 11:00:37 +02:00
Ben Noordhuis
be1032431d Merge branch 'v0.8' 2012-07-29 03:13:21 +02:00
Ben Noordhuis
4fe1916926 linux: fix 'two watchers, one path' segfault
Problem: registering two uv_fs_event_t watchers for the same path, then closing
them, caused a segmentation fault. While active, the watchers didn't work right
either, only one would receive events.

Cause: each watcher has a wd (watch descriptor) that's used as its key in a
binary tree. When you call inotify_watch_add() twice with the same path, the
second call doesn't return a new wd - it returns the existing one. That in turn
resulted in the first handle getting ousted from the binary tree, leaving
dangling pointers.

This commit addresses that by storing the watchers in a queue and storing the
queue in the binary tree instead of storing the watchers directly in the tree.

Fixes joyent/node#3789.
2012-07-28 16:31:47 +02:00
Ben Noordhuis
ec76a42515 test: add uv_loop_t to benchmark-sizes.c 2012-07-28 14:56:36 +02:00
Ben Noordhuis
4fe369b179 test: add uv_fs_event_t to benchmark-sizes.c 2012-07-28 14:48:47 +02:00
Ben Noordhuis
b5b8ead808 test: add failing fs_event test
Watches the same file twice. Fails on Linux with a segmentation fault.
2012-07-28 14:40:03 +02:00
Ben Noordhuis
912348261e include: update confusing uv_write comment 2012-07-27 16:04:13 +02:00
Ben Noordhuis
cf05c5f0d6 Raise UV_ECANCELED on premature close.
Set the error code to the more appropriate UV_ECANCELED instead of UV_EINTR
when the handle is closed and there are in-flight requests.
2012-07-27 15:13:29 +02:00
Ben Noordhuis
9f59e8e38c include: update uv_close documentation 2012-07-27 14:44:06 +02:00
Shuhei Tanuma
22f004db61 unix: don't abort() when trylock functions return EBUSY
Fixes #500.
2012-07-26 00:11:46 +02:00
Ben Noordhuis
94355e4718 unix: fix format string vulnerability in freebsd.c
uv_set_process_title() was susceptible to a format string vulnerability:

  $ node -e 'process.title = Array(42).join("%s")'
  Segmentation fault: 11 (core dumped)

The fix is trivial - call setproctitle("%s", s) instead of setproctitle(s) -
but valgrind complains loudly about reads from and writes to uninitialized
memory in libc. It's not a libuv bug because the test case below triggers the
same warnings:

  #include <sys/types.h>
  #include <unistd.h>

  int main(void)
  {
    setproctitle("%s", "test");
    return 0;
  }

That's why this commit replaces setproctitle() with sysctl(KERN_PROC_ARGS).

This commit reapplies commit a9f6f06, which got reverted in 69a6afe. The revert
turned out to be unnecessary.
2012-07-19 16:26:54 +02:00
Ben Noordhuis
ff59525c7e unix: fix uv_pipe_connect() with existing fd
Don't create a new socket descriptor if one has been previously assigned with
uv_pipe_open().
2012-07-19 16:25:49 +02:00
Ben Noordhuis
e3a28508b2 unix: fix errno reporting in uv_pipe_connect()
Remember the errno when the socket() syscall fails.
2012-07-19 16:13:44 +02:00
Ben Noordhuis
69a6afea63 unix: undo changes to uv_set_process_title()
It's making node.js crash when run as root. Backtrace:

  (gdb) bt
  #0  0x00007fff856e3ff9 in __findenv ()
  #1  0x00007fff856e404c in getenv ()
  #2  0x000000010004c850 in loop_init (loop=0x10045a792, flags=8) at ev.c:1707
  #3  0x000000010004cb3b in ev_backend [inlined] () at /Users/tjfontaine/Development/node/deps/uv/src/unix/ev/ev.c:2090
  #4  0x000000010004cb3b in ev_default_loop (flags=1606417108) at ev.c:2092
  #5  0x000000010004e5c6 in uv__loop_init (loop=0x10066e330, default_loop=1) at loop.c:52
  #6  0x0000000100044367 in uv_default_loop () at core.c:196
  #7  0x0000000100004625 in node::Init (argc=1606417456, argv=0x100b0f490) at node.cc:2761
  #8  0x000000010000797d in node::Start (argc=1606417600, argv=0x0) at node.cc:2888
  #9  0x0000000100000ca4 in start ()

This reverts commits:

  b49d6f7 unix: fix uv_set_process_title()
  a9f6f06 unix: fix format string vulnerability in freebsd.c
  a87abc7 unix: avoid buffer overflow in proctitle.c
  dc97d44 unix: move uv_set_process_title() to proctitle.c
2012-07-18 22:54:39 +02:00
Ben Noordhuis
b49d6f7c30 unix: fix uv_set_process_title()
Use strncpy() to set the process title, it pads the remainder with nul bytes.
Avoids garbage output on systems where `ps aux` prints the entire proctitle
buffer, not just the characters up to the first '\0'.

Fixes joyent/node#3726.
2012-07-18 00:26:02 +02:00
Ben Noordhuis
a9f6f06fea unix: fix format string vulnerability in freebsd.c
uv_set_process_title() was susceptible to a format string vulnerability:

  $ node -e 'process.title = Array(42).join("%s")'
  Segmentation fault: 11 (core dumped)

The fix is trivial - call setproctitle("%s", s) instead of setproctitle(s) -
but valgrind complains loudly about reads from and writes to uninitialized
memory in libc. It's not a libuv bug because the test case below triggers the
same warnings:

  #include <stdio.h>
  #include <stdlib.h>
  #include <sys/types.h>
  #include <unistd.h>

  int main(void)
  {
    setproctitle("%s", "test");
    return 0;
  }

That's why this commit replaces setproctitle() with sysctl(KERN_PROC_ARGS).
2012-07-13 17:16:38 +02:00
Ben Noordhuis
a87abc7070 unix: avoid buffer overflow in proctitle.c
Get/set process title with uv_strlcpy(), not strncpy(). The latter won't
zero-terminate the result if the destination buffer is too small.
2012-07-13 15:03:39 +02:00
Fedor Indutny
dc97d44c56 unix: move uv_set_process_title() to proctitle.c
Use hijacking argv array to change process' title. It seems to be working fine
on almost every platform (at least it should not break anything as it's used in
nginx in a similar way).
2012-07-13 14:57:40 +02:00
Fedor Indutny
3726dee5e9 unix: thread: use mach semaphores on osx 2012-07-10 14:14:50 +02:00
Ben Noordhuis
ad382bcac0 test: add missing return statement 2012-07-09 18:46:57 +02:00
Ben Noordhuis
c5761f72b3 unix: speed up uv_async_send() some more still
__sync_val_compare_and_swap() emits a CMPXCHG instruction on i386 and x86_64.
Use XCHG instead, it's about four times faster.
2012-07-09 02:46:19 +02:00
Ben Noordhuis
be09be7f3e unix: fix memory corruption in freebsd.c 2012-07-04 14:06:35 +02:00
Ben Noordhuis
68b0c85c09 test: allow 80 ms intervals in hrtime test
The hrtimer functionality on my FreeBSD 9 system is fairly coarse, it's usually
just over the 60 ms that we tested for before this commit.
2012-07-03 22:33:10 +02:00
Ben Noordhuis
5031a5b85a unix: rename linux/core.c to linux/linux-core.c
This is a back-port of commit e1320757 from the master branch.

Newer versions of gyp do not support files with the same basenames (example:
core.c and linux/core.c).

The nominal reason is consistency across build systems. Apparently, msbuild
doesn't support it either.

Somewhere, someplace, baby Jesus cries sad little tears...

Fixes #464.
2012-07-03 20:51:32 +02:00
Ben Noordhuis
3d9c1ebfeb unix: speed up uv_async_send() some more
Use atomic compare-and-swap to detect if we've been preempted by another thread
and therefore can avoid making the expensive write() syscall.

Speeds up the heavily contended case by about 1-2% and has little if any impact
on the non-contended case. I wasn't able to measure the difference at any rate.
2012-07-02 04:30:48 +02:00
Ben Noordhuis
a2204abc8e bench: improve async_pummel benchmark
Benchmark the performance of uv_async_send() when the handle is contended for
by 1, 2, 4 or 8 threads.
2012-07-02 03:57:15 +02:00
Ben Noordhuis
cc1b3de247 unix: revert 0971598, obsoleted by 889ab21 2012-07-02 00:00:20 +02:00
Ben Noordhuis
889ab216ae unix: fix 'zero handles, one request' busy loop
Fixes #484.
2012-07-01 23:59:30 +02:00
Ben Noordhuis
3b8c0da5a5 unix: fix busy loop on unexpected tcp message
Don't start reading immediately after connecting. If the server sends a message
and the client hasn't called uv_read_start() yet, the event loop will busy loop
because the pending message keeps waking it up.
2012-06-30 03:25:56 +02:00
Ben Noordhuis
1d1dd9bb7d test: add 'unexpected read' tcp test
Regression test that verifies that the event loop doesn't busy loop when
the server sends a message and the client isn't reading.
2012-06-30 03:25:52 +02:00