Commit Graph

2052 Commits

Author SHA1 Message Date
Ben Noordhuis
b607a7fed7 linux: move files out of src/unix/linux
Flattens the source tree and simplifies the Makefile.
2013-01-29 17:07:41 +01:00
Ben Noordhuis
75dea933eb build: support out of tree builds
Invoking make with builddir_name=/path/to/dir builds libuv in the
designated directory.
2013-01-29 17:07:25 +01:00
Ben Noordhuis
01fe4e73a6 build: add OS= make switch
Overrides the platform detection heuristic. Useful for cross-compiling.
2013-01-29 14:44:13 +01:00
Ben Noordhuis
93f61b7c3f unix: fix style issues in udp.c 2013-01-27 14:50:09 +01:00
Bert Belder
e4d8cbac78 unix: support sending uv_udp_t handles over ipc pipes 2013-01-22 23:58:13 +01:00
Ben Noordhuis
cf1dc61317 test: remove .travis.yml
Travis CI was generating a lot of false positives (or rather, false
negatives - tests that fail due to the environment they run in) and
it's been in a continuous error state for days now.

Remove it, we'll set up something ourselves.
2013-01-22 16:49:08 +01:00
Ben Noordhuis
7841f77b2e build: don't export _POSIX_C_SOURCE on non-linux
Don't export _POSIX_C_SOURCE to dependents. On the BSDs (and the
BSD-ish, like OS X), it hides SysV and BSD definitions.

The exception is Linux: _POSIX_C_SOURCE=200112 unlocks some of the
newer pthreads features like spinlocks and barriers, so keep
exporting it on that platform.
2013-01-22 16:19:52 +01:00
Andrius Bentkus
bdb498f8b1 unix, windows: return UV_EINVAL, not UV_EFAULT
A wrong multicast membership should return EINVAL.
2013-01-22 15:41:55 +01:00
Andrius Bentkus
017e2d5fde unix, windows: make uv_*_bind() error codes consistent
Just like uv_tcp_connect() it should return an EINVAL when the handle
is of an invalid type or when the network address is faulty.
2013-01-18 12:18:23 +01:00
Ben Noordhuis
372ac34d5f linux: translate futimes() fallback error codes
The fallback added in 9d4a16e uses the /proc filesystem to emulate
utimensat().

Translate error codes that indicate no procfs is mounted to ENOSYS.
Letting those error codes through unchecked will only confuse callers.
2013-01-17 18:43:07 +01:00
Ben Noordhuis
358957cdec doc: update gyp build instructions 2013-01-17 16:47:30 +01:00
Ben Noordhuis
9d4a16eefe linux: add futimes() fallback
The utimensat() syscall was added in 2.6.22. Add a fallback mode for
older kernels that uses utimes("/proc/self/fd/<fd>").

Fixes #687.
2013-01-17 14:22:55 +01:00
Ben Noordhuis
629a59b35b linux: use stdint types in structs
Use the typedefs from stdint.h to avoid build breakage on systems
where __u64 and friends are hidden when --std=c89 is in effect.

Fixes #685.
2013-01-17 01:29:47 +01:00
Ben Noordhuis
e7f384f853 test: make threadpool tests valgrind-compliant
Delete the event loop after the test to stop valgrind from complaining
about memory leaks.
2013-01-16 23:59:58 +01:00
Ben Noordhuis
4ba03ddd56 unix, windows: rename uv_run2 to uv_run
This changes the prototype of uv_run() from:

  int uv_run(uv_loop_t* loop);

To:

  int uv_run(uv_loop_t* loop, uv_run_mode mode);

Where `mode` is UV_RUN_DEFAULT, UV_RUN_ONCE or UV_RUN_NOWAIT.

Fixes #683.
2013-01-16 23:35:29 +01:00
Ben Noordhuis
4cbd5c7b32 test: remove bad tcp_write_error test
It makes the assumption that if you try to write to a localhost socket
often enough, eventually its send queue will fill up - which doesn't
happen if the machine it's running on is fast enough.
2013-01-16 00:31:21 +01:00
Ben Noordhuis
768b524639 unix: make stream.c more DRY 2013-01-14 16:53:35 +01:00
Ben Noordhuis
c931e31746 unix: make assertion message more descriptive 2013-01-14 11:32:55 +01:00
Ben Noordhuis
8e3e60ffbf linux: only pack struct uv__epoll_event on x86_64
On i386, it does not need packing; it's 12 bytes packed or unpacked.

On ARM, it's actively harmful: the struct is 12 bytes when packed and
16 bytes when unpacked.
2013-01-13 00:58:05 +01:00
Ben Noordhuis
9cd9bd33b4 build: fix host/target arch detection
Setting the target_arch without setting the host_arch as well was
effectively broken.
2013-01-13 00:51:53 +01:00
Ben Noordhuis
9aab5d4837 Revert "unix: improve uv_guess_handle() implementation"
This reverts commit 98bcddc8dd.

It's making a lot of tests in the node.js test suite fail.
2013-01-11 13:40:25 +01:00
Ben Noordhuis
fc42885d0e unix: set closed fd to -1, avoid double close bugs
* abort() if close() fails
* set fd to -1 after close() to prevent double close bugs
2013-01-11 13:39:39 +01:00
Ben Noordhuis
2ec2a5194f unix: clean up code in process.c 2013-01-11 13:38:01 +01:00
Ben Noordhuis
6f679a4ff7 unix: don't swap stdin file descriptors
Bug introduced in 47f496a. It turns out the file descriptors of the
stdin pipe don't have to be swapped around.
2013-01-11 13:32:00 +01:00
Bruce Mitchener
2cecd0d3d1 include: fix typos in comments 2013-01-10 15:12:02 +01:00
Ben Noordhuis
80f6a9c643 unix: omit second fcntl() call if possible
Omit the fcntl() syscall when the O_NONBLOCK or FD_CLOEXEC is already
set/clear because it's a no-op in that case.
2013-01-10 01:25:40 +01:00
Ben Noordhuis
9eedd32e40 build: make clean target remove libuv.{a,so,dylib} 2013-01-09 17:26:21 +01:00
Tim Bradshaw
bc0c61cd7f linux: ensure that all CPUs have model information 2013-01-08 05:29:21 +01:00
Ben Leslie
98bcddc8dd unix: improve uv_guess_handle() implementation
uv_guess_handle is currently squelching both fifo and all
sockets on to the UV_NAMED_PIPE type. Rather than treating
all sockets as UV_NAMED_PIPE, use getsockopt() and
getsockaddr() to determine if the socket is an AF_UNIX
stream (in which case return UV_NAMED_PIPE), or an AF_INET
stream (in which case return UV_TCP), or an AF_INET datagram
socket (in which case return UV_UDP).

Additionally, currently all other file descriptor types are
squelched to the UV_FILE type. Instead, only file descriptors
that are marked as regular files are treated as UV_FILE. All
other types (such as directories, character and block devices)
are now treated as UV_UNKNOWN_HANDLE.
2013-01-08 05:26:58 +01:00
Ben Noordhuis
cb3c448d8f unix: fix GNU-ism introduced in edd1007
Don't use features.h, it's only available on GNU/glibc systems.
2013-01-07 15:43:58 +01:00
Ben Noordhuis
f24335d498 test: fix #if defined checks
Same as edd1007 but this time for the tests.
2013-01-06 22:36:54 +01:00
Ben Noordhuis
fb725c0893 test: simplify tcp_ref2b
Said test doesn't need its own close callback, it can piggyback on the
common close callback.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
ccb96b67df test: remove unused function declaration 2013-01-06 22:31:48 +01:00
Ben Noordhuis
847182cdf1 test, bench: make functions/variables static
Make functions and variables that are local to the compilation unit
static. Remove what turns out to be unused.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
7ff6f29b85 test, bench: ANSI-fy function prototypes
Replace `void f()` with `void f(void)`; the former means "a function
that takes any number of arguments, including none" while the latter
is what is actually intended: a function taking no arguments.

The first form also isn't strictly conforming ANSI/ISO C.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
fa9c577e55 linux: fix race in uv_resident_set_memory()
uv_resident_set_memory() used a global buffer to read data into, which
is a decidedly unsafe thing to do in a multi-threaded environment.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
5b63285805 unix, windows: ANSI-fy uv_tty_reset_mode() prototype 2013-01-06 22:31:47 +01:00
Ben Noordhuis
edd10071eb unix: fix up #if defined checks
`#if FOO` (where FOO is undefined) is a legal construct in C89 and C99
but gcc, clang and sparse complain loudly about it at higher warning
levels.

Squelch those warnings. Makes the code more consistent as well.
2013-01-06 22:31:47 +01:00
Ben Noordhuis
e62dd3caa0 unix: fix include in cygwin.c 2013-01-06 21:25:58 +01:00
Ben Noordhuis
a2bedc0a7e unix: make uv__read_start_common() static 2013-01-06 21:25:58 +01:00
Ben Noordhuis
35b159a83e unix: make uv__work_cancel() static 2013-01-06 21:25:58 +01:00
Ben Noordhuis
0a06c2f3b2 unix: fix up function prototypes in signal.c 2013-01-06 21:25:58 +01:00
Ben Noordhuis
87cbf8d0c2 unix: remove unused function uv__strlcpy() 2013-01-06 21:25:58 +01:00
Ben Noordhuis
345eb6394f unix: add checksparse.sh script 2013-01-06 21:25:58 +01:00
Ben Noordhuis
1f52fc1c5a test: remove consumer_producer test
It fails intermittently on Travis for no other reason than that Travis
is occasionally slow. Reduce the number of false positives, remove the
test.
2013-01-06 19:19:23 +01:00
Ben Noordhuis
2f55353490 unix: update loop->time after poll
Fixes a bug where timers expire prematurely when the following
conditions hold:

  a) libuv first spends some time blocked in the platform poll function
  b) a callback then calls uv_timer_start()

Cause: uv_timer_start() uses an out-of-date loop->time in its
'when should the timer callback run?' calculations.

Solution: Update loop->time before invoking any callbacks.

Fixes #678.
2013-01-06 18:30:03 +01:00
Ben Noordhuis
339033afc0 unix: use uv__hrtime() internally
This commit renames the various uv_hrtime() implementations to uv__hrtime().

Libuv uses the high-res timer internally in performance-critical code paths.
Calling the non-public version avoids going through the PLT when libuv is
compiled as a shared object.

The exported uv_hrtime() now has a single definition in src/unix/core.c that
calls uv__hrtime().

A future optimization is to lift the uv__hrtime() declarations into header
files so they can be inlined at the call sites. Then again, linking with -flto
should accomplish the same thing.
2013-01-06 17:35:34 +01:00
Fedor Indutny
ba83510fc0 stream: fix infinite select() polling on osx
Interruption FD buffer should be emptied after write, otherwise select()
loop will poll indefinitely.
2013-01-04 21:10:33 +04:00
Ben Noordhuis
775f2c1f53 unix: remove stale closing check in uv__write()
Introduced in 0db3274f but no longer necessary; uv__write() no longer
runs when the handle has been closed. Write callbacks receive a special
status code that informs them that the handle has been closed.
2013-01-02 18:05:32 +01:00
Ben Noordhuis
a657e7f576 unix: remove uv_write_queue_head() 2013-01-02 17:45:37 +01:00