Commit Graph

222 Commits

Author SHA1 Message Date
Saúl Ibarra Corretgé
a6fa3ca99a unix: don't block for io if any io handle is primed
PR-URL: https://github.com/libuv/libuv/pull/347
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-05-12 07:37:26 +02:00
Saúl Ibarra Corretgé
e6e8124b95 test: add test for deferred TCP write failure
The test exhibits that write failures are deferred to the callback.

Refs: https://github.com/libuv/libuv/issues/339
PR_URL: https://github.com/libuv/libuv/pull/344
2015-05-05 23:25:49 +02:00
Fedor Indutny
e19089f7b1 stream: use SO_OOBINLINE on OS X
In the collaboration with Ben Noordhuis <info@bnoordhuis.nl> and
Saúl Ibarra Corretgé <saghul@gmail.com>.

Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-24 22:34:01 +03:00
Ben Noordhuis
b36d4ff930 unix: implement uv_stream_set_blocking()
Commit 393c1c5 ("unix: set non-block mode in uv_{pipe,tcp,udp}_open")
causes a regression in the io.js cluster module.

The io.js documentation states that `worker.send()` and `process.send()`
are synchronous but they no longer were after upgrading to libuv v1.2.1.

The reason they are synchronous is because of backpressure - or rather,
lack of backpressure: a slow consumer eventually causes a fast producer
to run out of memory because the backlog of pending messages in the
producer can grow unchecked.

Ergo, implement uv_stream_set_blocking() on UNIX platforms to let io.js
enable the old blocking behavior for pipes again.

Refs: https://github.com/iojs/io.js/issues/760
PR-URL: https://github.com/libuv/libuv/pull/187
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-02-09 13:28:52 +01:00
Ben Noordhuis
965fffc2e9 build: compile -D_GNU_SOURCE on linux
Fixes a number of -Wimplicit-function-declaration warnings for functions
that are behind _GNU_SOURCE on old systems, like strndup() and pread().

PR-URL: https://github.com/libuv/libuv/pull/162
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-24 18:28:26 +01:00
Johan Bergström
434ce034e0 build: make dist now generates a full tarball
Autotools tries to figure out what's necessary to create a tarball through
included files in Makefile.am. Since libuv has conditionals based on target OS
as well as additional samples/documentation, extra_files needs to include these.

Also, add the result of make dist to gitignore.

PR-URL: https://github.com/libuv/libuv/pull/118
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-11 11:41:59 +01:00
Ben Noordhuis
e6e871ac1c build: move flags from Makefile.am to configure.ac
Move compile-time flags that are not platform-specific defines to
configure.ac where they can be properly feature-detected.

PR-URL: https://github.com/libuv/libuv/pull/24
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-05 17:46:02 +01:00
Ben Noordhuis
751ac48baa linux: fix epoll_pwait() sigmask size calculation
Revisit the fix from commit b705b53.  The problem with using sigset_t
and _NSIG is that the size of sigset_t and the value of _NSIG depend
on what headers libuv picks up first, <signal.h> or <asm/signal.h>.
With the former, sizeof(sigset_t) = 128; with the latter, it's 8.

Simply sidestep the issue by calculating the signal mask as a 64 bits
integer, without using sigset_t or _NSIG.

PR-URL: https://github.com/libuv/libuv/pull/83
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-25 14:37:02 +01:00
John Marino
3ccd95ec67 build: fix dragonflybsd autotools build
Fixes multiple definition linker errors due to what seems to be multiple
inclusions of src/unix/freebsd.c and src/unix/kqueue.c.

Fixes #72, refs joyent/libuv#1576.

PR-URL: https://github.com/libuv/libuv/issues/72
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-16 15:06:16 +01:00
Luis Lavena
4203ef202c win: fix autotools build of tests
Add missing test file to match GYP definition and solve undefined
reference.

PR-URL: https://github.com/libuv/libuv/pull/69
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-14 16:05:45 +01:00
Ben Noordhuis
cb5140023b build: remove dtrace probes
The existing probes, all two of them, cause a great deal of pain for
people trying to build libuv on Linux because of SystemTap's dtrace(1)
utilitity not understanding the -xnolibs flag.

We could hack around that but it's easier to just remove the probes:
they are largely useless and unused while still needing a lot of
supporting infrastructure.  This commit removes 200 lines of code
and configuration.

Refs joyent/libuv#1478.
2014-11-10 20:12:50 -03:00
Tomasz Kołodziejski
59658a8de7 unix, windows: add uv_thread_equal 2014-10-20 09:51:49 +02:00
Robin Hahling
3193b67ff0 build: add DragonFly BSD support in autotools 2014-09-27 11:25:59 +02:00
Rob Adams
1cc25170ed build: add missing fixtures to distribution tarball 2014-09-22 08:27:16 +02:00
Saúl Ibarra Corretgé
5ccdfc568d test: add test for closing and recreating default loop 2014-09-15 21:34:09 +02:00
Fedor Indutny
145b76b894 darwin: allocate enough space for select() hack
`fd_set`s are way too small for `select()` hack when stream's fd is
bigger than 1023. Make `fd_set`s a part of `uv__stream_select_t`
structure.

fix #1461
2014-09-08 08:37:36 +01:00
Saúl Ibarra Corretgé
e524f89beb core: update version to 1.0.0 2014-08-29 10:31:50 +02:00
Bert Belder
6941cab549 windows: fix buffer leak after failed udp send
Fixes #1426

Signed-off-by: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-08-28 08:41:43 +02:00
Saúl Ibarra Corretgé
4ca9a36389 unix, windows: add uv_fileno
Returns the platform specific file descriptor for handles that are
backed by one. The datatype is abstracted as uv_os_fd_t, which maps to
int on Unices and HANDLE on Windows.

Users can use this function to set specific socket options, for example,
in a non portable way.

This function is essentially a shotgun, you better be careful with
whatever you do with it, don't blame me if you used it to get the fd of
a stream, close it yourself and expect things to Just Work.
2014-08-27 10:53:40 +02:00
Saúl Ibarra Corretgé
bd0692e65a build: use same CFLAGS in autotools build as in gyp
Closes #1362
2014-08-24 15:19:26 +02:00
Andrius Bentkus
d5e6f4372f unix: fix tcp write after bad connect freezing
If the connect wouldn't go off (no such tcp remote or any other failure),
the subsequent writes made would not be called. Now we call the writes
in the queue with ECANCELED if the connect fails.

Fix #1432
2014-08-21 16:23:43 +02:00
Julien Gilli
1552184238 unix: read on stream even when UV__POLLHUP set.
This fixes a SmartOS specific issue that happens when reading from
a stream that is the reading end of a pipe that has been closed by
the parent process.

In this case, a UV__POLLHUP event would be set on the stream and would
prevent the event loop from closing it. As a result, the event loop
would think there are stil handles open, and leave the process
hanging.

Fixes #1419.
2014-08-18 09:06:27 -07:00
Andrius Bentkus
0ecee213ea unix, windows: add uv_recv_buffer_size and uv_send_buffer_size 2014-08-09 11:36:35 +02:00
Andrew Low
cdc979dbe0 aix: improve AIX compatibility 2014-07-22 22:57:24 +02:00
Andrius Bentkus
960eefb319 unix: guarantee write queue cb execution order in streams
The problem was that the canceled write callbacks
were being called before the already written callbacks, even
though they were queued after them.
2014-07-18 13:16:10 +02:00
Saúl Ibarra Corretgé
817c09257d unix: remove incorrect assert
After 41891222bc landed it's possible that uv__udp_sendmsg is called
even if there are no pending write nor write completed requests:

1. User calls uv_udp_send and the request is sent immediately. The
   request is the added to the completed queue and we 'feed' the uv__io
   handle so that we process the completed request in the next
   iteration.
2. User calls uv_udp_send again but the request is not completed
   immediately, so it's queued in the write_queue.
3. The uv__io handle gets a UV__POLLOUT event and uv__udp_sendmsg is
   run, which completes the send request and puts it in the
   write_completed_queue. Afterwards, uv__udp_run_completed is executed
   and the write_completed queue is drained.
4. At this point, the uv__io handle was made pending in step 3, in
   uv__udp_sendmsg, but we no longer have requests to write or to complete,
   so we skip processing.
2014-07-11 22:53:59 +02:00
Andrius Bentkus
0d43992c3b unix, win: add uv_udp_try_send
The function returns UV_EAGAIN if the queue is not empty and
the message couldn't be sent immediately.
2014-07-04 18:30:33 +02:00
Saúl Ibarra Corretgé
8d11aacb79 unix, windows: use the same threadpool implementation 2014-06-27 14:27:04 +02:00
Leith Bade
cf7b81230b build: add pthread-fixes.c to Makefile.am on Android 2014-06-19 22:58:52 +02:00
Saúl Ibarra Corretgé
eee4776549 windows: fix handling closed socket while poll handle is closing
fixes #1278
2014-05-30 19:19:36 +02:00
Rasmus Christian Pedersen
70c42563c1 unix, windows: getnameinfo implementation
Closes #852
2014-05-20 17:33:52 +02:00
Saúl Ibarra Corretgé
3558d65d2f unix, windows: do not set SO_REUSEADDR by default on udp
Add UV_UDP_REUSEADDR flag instead, which can be passed to uv_udp_bind.
If the udp handle is unbound when uv_udp_set_memberhsip or
uv_udp_set_multicast_interface is called, the handle will be bound with
UV_UDP_REUSEADDR set.
2014-04-02 01:21:35 +02:00
Saúl Ibarra Corretgé
08327a7cbd unix, windows: add IPv6 support for uv_udp_multicast_interface 2014-03-28 00:39:09 +01:00
Saúl Ibarra Corretgé
7c5ab1a73e unix, windows: add IPv6 support to uv_udp_set_membership
Reworked from initial version by @snoj
2014-03-17 22:11:28 +01:00
Javier Hernández
a2506c9362 android: add support of ifaddrs in android
Fixes https://github.com/joyent/node/issues/7291
2014-03-16 23:16:25 +01:00
Saúl Ibarra Corretgé
72337966d4 build: fix SunOS and AIX build with autotools 2014-03-12 22:40:56 +01:00
Timothy J Fontaine
bbcc0c963c build: freebsd link with libelf if dtrace enabled 2014-03-12 21:58:44 +01:00
Fedor Indutny
b05a3ee4d1 pipe: allow queueing pending handles
Introduce `int uv_pipe_pending_count(uv_pipe_t*)` and
`uv_handle_type uv_pipe_pending_type(uv_pipe_t*)`. They should be
used in IPC pipe's read cb to accept incoming handles:

    int count = uv_pipe_pending_count(pipe);
    int i;
    for (i = 0; i < count; i++) {
      uv_handle_type type = uv_pipe_pending_type(pipe);
      /* ... */
      uv_accept(...);
    }
2014-03-04 00:34:29 +04:00
Saúl Ibarra Corretgé
5ac214c712 unix, windows: add uv_pipe_getsockname 2014-02-23 20:25:20 +01:00
Saúl Ibarra Corretgé
787f5fff92 unix, windows: add uv_loop_init and uv_loop_close
These functions supersede uv_loop_new and uv_loop_delete.
uv_loop_init initialized a user allocated loop and uv_loop_close
removes all associated resources a loop uses after it has finished
execution.

uv_loop_new and uv_loop_delete are now deprecated.
2014-02-21 09:56:13 +01:00
Ben Noordhuis
f17c535b73 unix: use a heap for timers
Replace the red-black tree with a heap.  The most common operation that
libuv performs on timers is looking up the first timer to expire.  With
a red-black tree, that operation is O(log n).  With a heap, it's O(1).
2014-02-19 13:36:14 +01:00
Saúl Ibarra Corretgé
d4c12adff6 include: expose libuv version in header files 2014-02-17 20:53:20 +01:00
Keno Fischer
a284b90c03 unix: correct error when calling uv_shutdown twice
Before this one of the requests was left as a ghost in the system.
See https://github.com/JuliaLang/julia/issues/5793
2014-02-15 16:37:58 +01:00
Saúl Ibarra Corretgé
419c2ffae7 test: fix udp multicast interface test 2014-02-10 08:56:39 +01:00
Bert Belder
140c863ff0 Merge branch 'v0.10'
Conflicts:
	build.mk
	Makefile.am
	test/test-ipc.c
2013-12-21 02:42:48 -08:00
Sam Roberts
ed36b85d3b unix, windows: add uv_loop_alive() function
Useful to know when the the event loop is empty, this can't be done with
uv_run() without possibly blocking, or running some events (which might
empty the event loop as a side-effect).
2013-12-19 15:35:03 -08:00
Fedor Indutny
b5e7798a89 stream: introduce uv_try_write(...)
`uv_try_write(stream, buf, size)` acts like `uv_write()`,
but without queueing actual write until UV_POLLOUT (or IOCP completion).
This is useful for doing writes using on-stack `uv_write_t` requests.

fix #1025
2013-12-13 22:29:00 +04:00
Yorkie
4ed6496b9c unix, windows: detect errors in uv_ip4/6_addr 2013-12-13 09:27:28 +01:00
Saúl Ibarra Corretgé
15af49a7a0 unix, windows: always update loop time
Fixes #846
2013-12-10 09:13:34 +01:00
Joshua Neuheisel
f44f8124e0 build: hide dtrace rules unless needed
When using configure, there are situations where libuv will attempt
to build uv-dtrace.h, even if it is configured with --disable-dtrace.
For example, if libuv is first configured with dtrace enabled, then
built, the .deps files will contain references to include/uv-dtrace.h.
After a make clean and configure --disable-dtrace, the build will still
attempt to create include/uv-dtrace.h and fail. make will see the
dependency reference (which survives the make clean), use the rule
(which is always added to the Makefile), and fail since DTRACE is not
defined.

This commit protects the rules to make uv-dtrace.h with the proper
conditionals to ensure the rules are not written if --disable-dtrace
is chosen.

Fix #963.
2013-12-09 11:25:55 +04:00
Andrej Manduch
6c063317b7 build: add support for pkg-config 2013-12-07 00:49:25 +01:00
Ben Noordhuis
27795cfc0f unix: fix accept() EMFILE error handling
Fix a bug that was introduced in commit 3ee4d3f ("unix, windows:
return error codes directly") and add a regression test for good
measure.

Hat tip to Fedor for pointing out the issue.

Fixes #1007.
2013-11-25 01:54:47 +01:00
Ben Noordhuis
c2c92fa65d build: add test-tcp-close-accept.c to test deps
Add test/test-tcp-close-accept.c to the dependency list of the
`make check` target of the autotools build.
2013-11-13 14:00:55 +01:00
Ben Noordhuis
24bfef2ef4 linux: handle EPOLLHUP without EPOLLIN/EPOLLOUT
Work around an epoll quirk where it sometimes reports just the EPOLLERR
or EPOLLHUP event.  In order to force the event loop to move forward,
we merge in the read/write events that the watcher is interested in;
uv__read() and uv__write() will then deal with the error or hangup in
the usual fashion.

Fixes #982.
2013-11-08 05:16:55 +01:00
Ben Noordhuis
fd723666af build: add test/test-watcher-cross-stop.c to list
Overlooked in the last v0.10 -> master merge.
2013-11-08 04:16:00 +01:00
Ben Noordhuis
7f44933c43 include: remove uv_strlcat() and uv_strlcpy()
It was pointed out that they don't quite work like their BSD namesakes
and they arguably shouldn't have been part of the API anyway.

Fixes #983.
2013-11-03 03:50:23 +01:00
Sean Farrell
4c6294e69b build: fix check target for mingw 2013-10-25 13:01:24 +02:00
Ben Noordhuis
150b6a71c9 unix: add spinlock.h
Add an atomic, non-blocking spinlock type.  The primary use case is to
have a mutex type that we can use while inside a signal handler.
2013-10-20 13:58:34 +02:00
Ben Noordhuis
a3c3b37bfb unix: add atomic-ops.h
Add cmpxchgi(), cmpxchgl() and cpu_relax() functions that we can use
as simple primitives to build spinlocks out of.
2013-10-20 13:58:34 +02:00
Timothy J Fontaine
717e0e5635 build: use -pthread on sunos
When building on sunos with autoconf make sure to specify -pthread
otherwise there will be race conditions with errno and etc
2013-09-20 10:50:19 -07:00
Saúl Ibarra Corretgé
2b9c374c1c windows: run close callbacks after polling for i/o
Makes the uv-win behavior compatible with uv-unix.

Fixes #796.
2013-09-06 06:28:42 +02:00
Brent Cook
c363cd0dba build: include internal headers in source list
Allows 'make dist-*' targets to generate working tarballs.
2013-09-04 01:09:42 +02:00
Ben Noordhuis
d48168afd0 darwin: remove CoreFoundation dependency
Load the required symbols at run-time rather than linking against the
CoreFoundation (and CoreServices and ApplicationServices) frameworks
at build time.

Should make integration easier for people that bundle libuv with their
own projects because they no longer have to replicate magic -framework
incantations in their top-level build system.
2013-08-27 23:58:21 +02:00
Keno Fischer
e52aa6cc57 build: make autotools build system work with mingw 2013-08-24 21:49:37 +02:00
Timothy J Fontaine
1a177d7028 build: apply dtrace -G to all object files
fixes #871
2013-08-12 09:48:25 -07:00
Ben Noordhuis
1510ce81fd unix, windows: allow NULL async callback
Allow a NULL callback so the user doesn't have to provide a dummy when
the actual event is processed by e.g. a check handle callback.
2013-08-12 08:55:51 +02:00
Ben Noordhuis
c82cea1ec5 build: enable AM_INIT_AUTOMAKE([subdir-objects])
Squelches (justified) warnings with automake 1.14.

Object files are built in subdirectories now so fix up the dtrace
postprocessing step to scan for *.lo files in said subdirectories.

Fixes #866.
2013-07-29 00:36:49 +02:00
Timothy J Fontaine
b13941cf17 build: dtrace shouldn't break out of tree builds
Fixes #848.
2013-07-25 12:12:48 +02:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Miroslav Bajtoš
fd45f876ff linux,darwin,win: link-local IPv6 addresses
Modified uv_ip6_addr() to fill sin6_scope_id for link-local addresses.

Fixes #271

Conflicts:
	build.mk
2013-07-04 15:43:20 +02:00
Timothy J Fontaine
2f3124a8c1 build: add DTrace detection for autotools 2013-07-03 16:04:01 -07:00
Ben Noordhuis
ddd7e04fd6 build: switch to autotools
Switch to the build tool everyone loves to hate.  The Makefile has
served us well over the years but it's been acquiring more and more
features that autotools gives us for free, like easy static+shared
library building, sane install targets, and so on.

This commit drops MinGW support.  If there is demand for it, we'll
re-add it.
2013-07-02 01:21:16 +02:00