Commit Graph

1920 Commits

Author SHA1 Message Date
Stephen Gallagher
e318b06a0e include: split off libev function prototypes
This patch creates a new header - ev-proto.h - which contains all of the
protoypes for libev functions. This allows us to create a shared object of
libuv without exposing libev internal functions.
2012-11-07 16:55:49 +01:00
Ben Noordhuis
91faa3e688 test: fix compiler warning
Fix the following warning by not using a static variable:

  test/test-fs-poll.c:79: warning: ‘static’ is not at beginning of declaration
2012-11-07 16:20:18 +01:00
Ben Noordhuis
a7cedbe220 darwin: fix uv_hrtime() thread safety issue 2012-11-07 16:20:18 +01:00
Bert Belder
0097280624 windows: map ERROR_GEN_FAILURE to UV_EIO 2012-11-07 11:11:23 +01:00
Ben Noordhuis
a320d46440 test: fix type casting style issue 2012-11-07 05:50:30 +01:00
Ben Noordhuis
7759bd63cd test: remove unnecessary #ifdef _WIN32 2012-11-06 00:32:04 +01:00
Bert Belder
6620e614ac windows: un-break the build
It was broken in 1d85815.
2012-11-05 22:11:22 +01:00
Ben Noordhuis
0ddf9d6b98 Revert "unix: use select() for specific fds on OS X"
This reverts commit 5da380a5ca.

Contains a bug that effectively makes the select() thread busy-loop. The file
descriptor is polled for both reading and writing, regardless of what events
the main thread wants to receive. Fixing that requires proper synchronization
between the two threads.

See #614.
2012-11-04 01:23:12 +01:00
Ben Noordhuis
20bb1bfd70 Revert "unix: reopen tty as /dev/tty"
This reverts commit 31f9fbce63.

The reverted commit depends on commit 5da380a ("use select() for specific fds
on OS X") which polls /dev/tty file descriptors in a separate thread to work
around deficiencies in the kqueue API on OS X.

Unfortunately, 5da380a has a bug that effectively makes the select() thread
busy-loop. Revert this commit for now.
2012-11-04 01:07:14 +01:00
Ben Noordhuis
b5fc9444b1 build: export _LARGEFILE_SOURCE, _FILE_OFFSET_BITS
Export compile-time defines that influence the size of struct stat.

This should avoid sizeof(struct stat) mismatches between libuv and dependent
projects.

On OS X, _DARWIN_USE_64_BIT_INODE=1 is also exported.
2012-11-04 00:58:49 +01:00
Ben Noordhuis
914185d6fc unix: make some internal methods static 2012-11-03 02:06:42 +01:00
Charlie McConnell
1d858156b4 unix: do not set environ unless one is provided
Currently, `uv_spawn` will set `environ` to the value of `options.env`, even if
`options.env` is `NULL`.  This results in child processes for whom `environ ==
NULL`, which can cause a variety of unexpected issues.
2012-11-03 01:37:22 +01:00
Ben Noordhuis
dcce1eab3b test: fix -Wmissing-field-initializers warnings 2012-11-02 14:34:28 +01:00
Ben Noordhuis
894a8523cb test: fix signed/unsigned comparison warnings 2012-11-02 14:32:14 +01:00
Ben Noordhuis
9c7ae2e7a3 darwin: don't use deprecated AbsoluteToNanoseconds 2012-11-02 14:23:26 +01:00
Ben Noordhuis
be597ba625 unix: set req type to UV_FS 2012-11-02 14:23:23 +01:00
Ben Noordhuis
b0bcbdfe81 unix: NULL pipe_fname in uv__pipe_close()
Pro-actively avoid use-after-free errors, set the pipe_fname field to NULL.
2012-11-01 15:51:06 +01:00
Ben Noordhuis
b8aa5b9bf2 test: don't assert on UV_EPIPE in echo-server.c
UV_EPIPE is not an error per se, it simply indicates that the other end of the
connection - i.e. the test case - has gone away.

Pro-actively ignore UV_ECANCELED errors. They're not actually emitted right now
because there's only ever one pending write but let's be forward compatible.
2012-11-01 15:39:11 +01:00
Ben Noordhuis
225c6f1719 unix, windows: fix several error messages 2012-11-01 14:49:21 +01:00
Ben Noordhuis
0d5d6504e5 unix, windows: fix EAGAIN error message 2012-11-01 14:03:38 +01:00
Leonard Hecker
97c527ac43 darwin: make it possible to compile for iOS
Relocate the include of TargetConditionals.h and fixe the use of
TARGET_OS_IPHONE. Furthermore, uv__fsevents_init() and uv__fsevents_close are
now empty functions for iOS, since the FSEvents API is not available there.
2012-10-29 23:45:52 +01:00
Bert Belder
149b16f123 windows: closing handles should always keep the loop alive
This makes the tcp-ref2 and udp-ref2 tests pass again.
Also adds another reference count test.
2012-10-25 15:10:29 +02:00
Ben Noordhuis
6150feda56 unix: fix ‘fd’ undeclared build error
Reapplies commit b5028c5b, failed to merge in 5cb4197.
2012-10-25 12:50:40 +02:00
Ben Noordhuis
5cb4197deb Merge branch 'v0.8' 2012-10-25 04:43:19 +02:00
Ben Noordhuis
f43ad85edd include: fix ngx_queue_foreach() macro
Guard against the possibility that the queue is emptied while we're iterating
over it. Simple test case:

  #include "ngx-queue.h"
  #include <assert.h>

  int main(void) {
    ngx_queue_t h;
    ngx_queue_t v[2];
    ngx_queue_t* q;
    unsigned n = 0;
    ngx_queue_init(&h);
    ngx_queue_insert_tail(&h, v + 0);
    ngx_queue_insert_tail(&h, v + 1);
    ngx_queue_foreach(q, &h) {
      ngx_queue_remove(v + 0);
      ngx_queue_remove(v + 1);
      n++;
    }
    assert(n == 1); // *not* 2
    return 0;
  }

Fixes #605.
2012-10-25 04:36:51 +02:00
Bert Belder
0dbab84529 benchmark: async_pummel should not call uv_async_send on closed handle
This fixes an assertion that triggered in debug builds on Windows.
2012-10-24 21:36:57 +02:00
Bert Belder
a54b9e2921 benchmark: timed_udp_pummel should not write to closed udp handle
This fixes intermittent assertion failures when running the benchmark.
2012-10-24 21:36:57 +02:00
Ben Noordhuis
31f9fbce63 unix: reopen tty as /dev/tty
Reopen the file descriptor when it refers to a tty. This lets us put the tty in
non-blocking mode without affecting other processes that share it with us.

Fixes #601.
2012-10-24 15:39:11 +02:00
Ben Noordhuis
b7f38b1e53 Revert "unix: avoid iterating over all async handles"
This reverts commit 209abbab27.

Fixes the following SIGSEGV:

  (gdb) f 1
  #1  0x00007fc084683aec in uv__async_io (loop=0x7fc0848e0b40,
  handle=0x7fc0848e0c78, events=1) at src/unix/async.c:175
  175             ASYNC_CB(h)
  (gdb) list
  170
  171         /* If we need to sweep all handles anyway - skip this loop */
  172         if (!loop->async_sweep_needed) {
  173           for (i = 0; i < end; i += sizeof(h)) {
  174             h = *((uv_async_t**) (buf + i));
  175             ASYNC_CB(h)
  176           }
  177         }
  178
  179         bytes -= end;
  (gdb) print *h
  $1 = {close_cb = 0x184e1b0, data = 0x18d9520, loop = 0x7fc0848e0b40,
  type = 49, handle_queue = {prev = 0x18dae10, next = 0x7860c0}, flags = 32,
  next_closing = 0x1863b40, pending = 0, async_cb = 0x31,
  queue = {prev = 0x18dae50, next = 0x7860c0}}
  (gdb)

It looks like the async handle gets closed or otherwise becomes invalid before
the sweep is executed.

Fixes #603.
2012-10-24 14:58:49 +02:00
saghul
61ecb3415d win: support compilation with Visual Studio 2008 2012-10-23 22:55:25 +02:00
Ben Noordhuis
c2478b2669 linux: update comm field in uv_set_process_title()
Makes the new process name visible in both `ps` and `ps a`, with the caveat
that `ps` will only print the first 16 characters.

Before this commit, `ps` kept reporting the old process name.
2012-10-22 13:44:56 +02:00
Ben Noordhuis
775064a3a5 linux: use /proc/cpuinfo for CPU frequency
Obtain the CPU frequency from /proc/cpuinfo because there may not be any
cpufreq info available in /sys. This also means that the reported CPU speed
from now on is the *maximum* speed, not the *actual* speed the CPU runs at.

This change only applies to x86 because ARM and MIPS don't report that
information in /proc/cpuinfo.

Fixes #588.
2012-10-21 00:08:21 +02:00
Ben Noordhuis
1bb1ba27dd unix: fix compiler warning in async.c
Include missing <string.h> header. Fixes the following compiler warning:

  src/unix/async.c:182:7: warning: implicit declaration of
  function ‘memmove’ [-Wimplicit-function-declaration]
2012-10-20 23:36:00 +02:00
Fedor Indutny
209abbab27 unix: avoid iterating over all async handles 2012-10-19 17:22:30 +02:00
Bert Belder
1e32cb01b5 unix: support signal handlers outside the main loop 2012-10-17 01:25:02 +02:00
Bert Belder
39d574dcff unix: make it possible to delay close callbacks 2012-10-17 01:25:00 +02:00
Bert Belder
47eb03490a test: move loop cleanup code to the individual tests 2012-10-17 01:24:49 +02:00
Bert Belder
28eb619c65 windows: don't run signal tests
They are dummy tests on windows, running them is misleading.
Also remove duplicate 'test-signal.c' entry from uv.gyp.
2012-10-16 17:23:04 +02:00
Bert Belder
c5e1140779 tests: fix some compile warnings on windows 2012-10-16 17:22:54 +02:00
Hiroaki Nakamura
36b1e1a57c test: change 10e8 to 1e9
It is clearer and used everywhere else.
2012-10-16 00:07:46 +02:00
Ben Noordhuis
fd136da04a unix: remove always_inline attribute
Fixes the following gcc 4.7+ warning:

  ../src/unix/internal.h:105:13: warning: always_inline function might not be
  inlinable [-Wattributes]

gcc wants the always_inline function to be annotated with the 'inline' keyword
which we can't do because we compile in C89 mode.

Using __inline is not an option because that makes clang generate warnings when
-Wlanguage-extension-token is enabled.

Therefore, remove the always_inline attribute altogether and hope that the
compiler is smart enough to inline the functions.
2012-10-15 01:08:47 +02:00
Ben Noordhuis
d8de4fbd13 build: compile with -fwrapv in debug mode 2012-10-15 00:52:27 +02:00
Ben Noordhuis
47b2cd31c9 build: rename uv.a to libuv.a 2012-10-11 14:32:06 +02:00
saghul
9a6f496985 win: fix compilation with MSVCRT < 8.0 2012-10-11 00:59:43 +02:00
Bert Belder
b0c1a3803a windows: fix handle leak in uv_fs_utime 2012-10-10 17:15:25 +02:00
Bert Belder
4900912d44 windows: fix application crashed popup in debug version
This is a backport of 2 patches by Ting-Yu Lin and Hiroaki Nakamura.
2012-10-10 17:15:25 +02:00
Ben Noordhuis
cb03e3bd26 darwin: work around concurrent write() kernel bug
Simultaneously writing from multiple threads to the same file descriptor is not
safe on OS X. We already serialized all pwrite() system calls, apply the same
workaround to the write() system call.

Fixes a node.js test, test/simple/test-fs-sir-writes-alot.js, that was failing
because parts of the output file got filled with nul bytes.
2012-10-10 02:15:54 +02:00
Ben Noordhuis
4affbe70b6 unix: remove unnecessary pthread_join ESRCH check
ESRCH means the thread never got started but we guard against that now.
2012-10-10 01:11:09 +02:00
Hiroaki Nakamura
acea3028c5 unix, windows: add thread barrier support 2012-10-09 17:30:52 +02:00
Hiroaki Nakamura
2684f876a9 windows: don't set CRT debug mode on MinGW 2012-10-09 17:00:02 +02:00