Commit Graph

1756 Commits

Author SHA1 Message Date
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
Ben Noordhuis
b5ad44d103 test: add uv_fs_poll_t to benchmark-sizes.c 2012-08-20 16:31:54 +02:00
Ben Noordhuis
83e00873b7 unix: fix const correctness compiler warning
This is a back-port of commit f97c80f from the master branch.
2012-08-20 16:18:38 +02:00
Bert Belder
201b8f935f Merge branch 'v0.8' 2012-08-18 03:57:41 +02:00
Tim Holy
ce87b7e14c unix: fix integer overflow in uv_hrtime
Conversion to nanoseconds was overflowing with 32-bit builds.
2012-08-18 03:55:13 +02:00
Bert Belder
9f0e00c7b3 unix: fix the build
uv_signal_t.signum was moved to uv.h in an earlier commit.
2012-08-17 19:41:14 +02:00
Bert Belder
c4dbb60cff windows: basic signal handling support with uv_signal_t
This still needs tests.
2012-08-17 19:38:29 +02:00
Bert Belder
95a742be02 Revert "windows: readable tty handles need access to console output"
This is not the way to go.
This reverts commit 1b929bfff5.
2012-08-17 19:38:28 +02:00
Ben Noordhuis
3b69c0f56d unix: split up uv-unix.h 2012-08-17 16:42:31 +02:00
Ben Noordhuis
ddd52773dd build: handle bad gcc -dumpversion output
`gcc -dumpversion` usually prints major.minor - but on sunos it prints
major.minor.patch.
2012-08-17 16:32:12 +02:00
Ben Noordhuis
a7f7696a8d unix: remove UV_REQ_BUFSML_SIZE 2012-08-17 15:19:40 +02:00
Ben Noordhuis
894b0fc0a7 unix: move platform init out of loop.c
Move platform-specific initialization logic out of loop.c and into the
platform files (freebsd.c, sunos.c, etc).
2012-08-17 14:48:52 +02:00
Bert Belder
1b929bfff5 windows: readable tty handles need access to console output
Readable tty handles need to be able to update the virtual window,
so if uv_tty_t is initialized with a console input fd, additionally
open the console output.
2012-08-17 00:10:18 +02:00
Bert Belder
88634c1405 windows: separate uv_tty_t read state from write state 2012-08-17 00:10:15 +02:00
Bert Belder
7cf1b67594 windows: small style fix in uv-win.h 2012-08-16 23:11:26 +02:00
Ben Noordhuis
22ce5a3412 sunos: fix uv_cpu_info() on x86_64
kstat_data_lookup("clock_Mhz") returns a KSTAT_DATA_INT32 on i386 but a
KSTAT_DATA_INT64 on x86_64.
2012-08-16 14:43:46 +02:00
Ben Noordhuis
90a75b0d84 include: update uv_timer doc comments 2012-08-15 23:08:31 +02:00
Bert Belder
938a30589c windows: tweak formatting inside uv-win.h 2012-08-15 03:13:58 +02:00
Ben Noordhuis
7cd400ef10 unix: report exit_status==-1 when execve() fails
Call exit_cb with exit_status==-1 when spawning a new process with uv_spawn()
fails.
2012-08-14 18:22:30 +02:00
Ben Noordhuis
54bfb66806 linux: improve /proc/cpuinfo parser
Make uv_cpu_info() understand the ARM and MIPS versions of /proc/cpuinfo,
it only knew how to deal with the x86 version

This commit also fixes a buglet where uv_cpu_info() reported the maximum CPU
frequency instead of the actual CPU frequency. That is, before this commit
`out/Debug/run-tests platform_output | grep speed | sort | uniq -c` on my
system always reported:

      8   speed: 3400

Now it reports (for example):

      2   speed: 3400
      6   speed: 1600

In other words, two CPUs are running at full speed while the others have been
scaled back because they're mostly idle.

Fixes #526.
2012-08-14 18:06:51 +02:00
Ben Noordhuis
f4f294f7c6 linux: remove bogus comment in linux-core.c 2012-08-14 12:45:18 +02:00
Bert Belder
7fb43d3c5b windows: move uv_atomic_exchange_set to atomicops-inl.h 2012-08-14 01:04:43 +02:00
Bert Belder
4442ddcaae windows: fix formatting issue in uv-win.h 2012-08-14 00:19:19 +02:00
Bert Belder
7c3ba514e7 windows: use WCHAR consistently 2012-08-13 22:31:48 +02:00
Bert Belder
aa69f34d53 windows: report spawn errors to the exit callback
Formerly spawn errors would be reported as a message printed to the
process' stderr, to match unix behaviour. Unix has now been fixed to
be more sensible, so this hack can now be removed.

This also fixes a race condition that could occur when the user closes
a process handle before the exit callback has been made.
2012-08-13 22:31:47 +02:00
Bert Belder
80eae82104 test: spawn failures are reported by setting the exit code to -1 2012-08-13 22:31:47 +02:00
Bert Belder
3f1f11f338 windows: use UV_ECANCELED to signal canceled requests
This used to be UV_EINTR, but that's not an appropriate error code in
this situation.
2012-08-13 22:31:46 +02:00
Bert Belder
1b8307637b test: fix intermittent failure of tcp_unexpected_read on windows 2012-08-13 22:31:46 +02:00
Bert Belder
c85672eb13 test: avoid compiler complaints about implicit double-to-int cast 2012-08-13 22:31:45 +02:00
Bert Belder
762c85c3ef windows: un-break the build 2012-08-13 22:31:45 +02:00
Ben Noordhuis
758a76922b unix: fix SIGCHLD race in process.c
Start the SIGCHLD signal watcher before calling fork(). There was a very subtle
race where a child process could quit (and generate a SIGCHILD) before the
signal handler was installed.

To reproduce, call uv_spawn() repeatedly with the below x86_64 program:

    // compile with `gcc -O2 -nostdlib`
    void _start(void)
    {
      // syscall(SYS_exit, 0)
      __asm__ __volatile__ (
        "xorq %rdi, %rdi;"
        "xorq %rax, %rax;"
        "mov $0x3c, %al;"
        "syscall;"
      );
      for (;;);
    }
2012-08-13 16:51:53 +02:00
Ben Noordhuis
9d7e300364 Merge branch 'v0.8' 2012-08-13 15:51:12 +02:00
Ben Noordhuis
2c3e8b6aa6 build: rework -fvisibility=hidden detection
Make the gcc_version macro conform with what node.js and v8 use. Important
because node.js's common.gypi is going to export it soon.
2012-08-13 15:29:21 +02:00
Ben Noordhuis
ac0d46851a unix: work around darwin bug, don't poll() on pipe
poll() on newer versions of OS X sets POLLHUP|POLLIN whereas older versions
(and other Unices) only set POLLHUP. It was tripping up a check that expected
to read data when POLLIN was set.

While easy to work around, I switched it to a blocking read instead:
it's less code and avoids surprises like the one above altogether.

Fixes #522.
2012-08-12 00:59:18 +02:00
Fedor Indutny
23dc564f3b darwin: emulate fdatasync() with fcntl(F_FULLFSYNC)
OS X has no public API for fdatasync. And as pointed out in `man fsync(2)`:

  For applications that require tighter guarantees about the integrity of
  their data, Mac OS X provides the F_FULLFSYNC fcntl. The F_FULLFSYNC
  fcntl asks the drive to flush all buffered data to permanent storage.
  Applications, such as databases, that require a strict ordering of writes
  should use F_FULLFSYNC to ensure that their data is written in the order
  they expect.  Please see fcntl(2) for more detail.
2012-08-11 23:43:51 +02:00
Ben Noordhuis
837edf4c0f unix, windows: remove handle init counters
Remove the handle init counters, no one uses them.
2012-08-10 02:00:11 +02:00
Ben Noordhuis
caa79af2ad unix: rework uv_eio_init() init once logic
Don't use counters.eio_init to track if libeio has been initialized, it's going
to be removed in a follow-up commit.
2012-08-10 02:00:11 +02:00
Ben Noordhuis
75ba681913 unix: remove dependency on ev_child 2012-08-10 02:00:11 +02:00
Ben Noordhuis
ee50db6e36 unix, windows: preliminary signal handler support
* a no-op on Windows for now
* only supports the main loop on UNIX (again, for now)
2012-08-10 02:00:07 +02:00