Commit Graph

1689 Commits

Author SHA1 Message Date
Bert Belder
36883f29ea win/udp: fix bug in getsockopt() return value check 2013-01-30 19:09:57 +01:00
Bert Belder
6b1cca3975 win/udp: make uv_udp_set_socket set UV_HANDLE_IPV6
This patch makes uv_udp_set_socket responsible for setting the
UV_HANDLE_IPV6 flag.

In addition, this patch fixes some minor style issues.
2013-01-30 19:09:57 +01:00
Bert Belder
c45564ac8a win/tcp: make uv_tcp_set_socket set UV_HANDLE_IPV6
This makes uv_tcp_set_socket responsible for setting the UV_HANDLE_IPV6
flag. This fixes a couple of situations where the the fact that a socket
is an IPv6 socket is not taken into account when deciding whether a call
to SetFileCompletionNotificationModes is appropriate.
2013-01-30 19:09:56 +01:00
Bert Belder
3382a923f5 win: fix uv_winsock_init crash when no IPv4 stack present
uv_winsock_init() tries to create an IPv4 socket in order to detect
if the system has any layered service providers (LSPs) installed.
When creating this socket failed it would call uv_fatal_error and exit
with the following message:

  socket: (10047) An address incompatible with the requested protocol was used.

This patch fixes that. It also includes some minor style tweaks.
2013-01-30 19:09:56 +01:00
Bert Belder
f0844ee760 win: add error mappings related to unsupported protocols 2013-01-30 19:09:55 +01:00
Bert Belder
d27d1e5078 win: sort error code mappings 2013-01-30 19:09:36 +01:00
Bert Belder
4c5c5d9aea windows: map ERROR_DIRECTORY to UV_ENOENT 2013-01-30 19:06:10 +01:00
Andrew Shaffer
49977386e9 sunos: properly disarm PORT_LOADED fsevent watcher
Fixes a segmentation fault when the watched entity is changed after the watcher
has been closed.
2012-12-14 12:02:57 +01:00
Bert Belder
527a10f904 windows: improve / fix uv_interface_addresses
* If GetAdaptersAddresses() failed, it would return UV_OK nonetheless,
  but the `adresses` and `count` out parameters would not be set.

* When adapters were enabled or added in between the two
  GetAdaptersAddresses() calls, it would fail.

* In case of an out of memory situation, libuv would crash with a fatal
  error.

* All interface information is now stored in a single heap-allocated
  area.
2012-12-04 14:05:50 +01:00
Bert Belder
c7fca7ad84 windows: add some error code mappings 2012-12-04 14:05:50 +01:00
Ben Noordhuis
deb1c34774 sunos: fix uv_getaddrinfo() NULL pointer dereference 2012-11-29 23:30:48 +01:00
Ben Noordhuis
5639b2f1f9 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.

This is a back-port of commit 775064a from the master branch.
2012-11-20 19:20:16 +01:00
Ben Noordhuis
72955c29c2 windows: map WSAESHUTDOWN to UV_EPIPE
This is a back-port of commit 483043b from the master branch.
2012-11-14 01:06:03 +01:00
Ben Noordhuis
deeec421af build: use link_settings, fix typo
* Use link_settings instead of direct_dependent_settings.
* Fix typo: s/ldlags/ldflags/

Pointed out by a certain R.L. Dahl of San Francisco, CA.

Fixes #618.
2012-11-09 20:22:42 +01:00
Bert Belder
f372fd4b13 windows: map ERROR_GEN_FAILURE to UV_EIO 2012-11-07 11:10:43 +01:00
Ben Noordhuis
2affa60e19 test: remove unnecessary #ifdef _WIN32
This is a back-port of commit 4d17337 from the master branch.
2012-11-06 00:35:39 +01:00
Bert Belder
4c9e42d0e6 windows: un-break the build
It was broken in fb64948.
2012-11-05 22:13:38 +01:00
Charlie McConnell
fb64948746 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.

This is a back-port of commit 1d85815 from the master branch.
2012-11-03 01:41:10 +01: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
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
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
Bert Belder
39ca621987 windows: don't blow up when an invalid FD is used 2012-09-22 03:50:30 +02:00
Charlie McConnell
b877db93ce unix: map EDQUOT to UV_ENOSPC 2012-09-21 17:08:27 +02:00
Ben Noordhuis
9a4838110d 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.

This is a back-port of commit 54bfb66 from the master branch.

Fixes #526.
2012-09-15 19:10:41 +02:00
Bert Belder
b2dc1e6d64 win/tty: reset background brightness when color is set to default 2012-09-14 17:50:45 +02:00
Ben Noordhuis
1988f5e581 unix: put child process stdio fds in blocking mode
Remove the O_NONBLOCK flag from file descriptors 0-2, most applications don't
expect EAGAIN errors when dealing with stdio.
2012-09-12 01:48:05 +02:00
Ben Noordhuis
b5028c5b54 unix: code cleanup, rename variable 2012-09-12 01:33:16 +02:00
Ben Noordhuis
12c25e1027 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 15:03:03 +02:00
Ben Noordhuis
33bcb63596 build: make gyp_uv understand '-f ninja' 2012-09-10 15:03:03 +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
24c062cc3e windows: fix memory corruption when closing shared server sockets 2012-08-30 17:25:32 +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
Ben Noordhuis
0ac2fdc554 unix: map errno ESPIPE 2012-08-23 00:32:56 +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
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
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
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
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
Bert Belder
a1157cef37 windows: don't duplicate invalid stdio handles
Ref: joyent/node#3779
2012-08-08 02:24:48 +02:00
Bert Belder
00d2f22151 windows: fix typos in process-stdio.c 2012-08-08 02:18:53 +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
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