Commit Graph

172 Commits

Author SHA1 Message Date
Fedor Indutny
f8e7513a06 darwin: use FSEvents to watch directory changes 2012-09-12 23:38:57 +02:00
Ben Noordhuis
ff0a93a04f unix: fix clang -Wlanguage-extension-token warnings 2012-09-01 00:27:57 +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
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
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
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
Ben Noordhuis
9f7cdb20aa unix: add relaxed accept() setting
Mitigates unfair scheduling in multi-process setups that share a single listen
socket across multiple processes.
2012-08-02 15:58:55 +02:00
Ben Noordhuis
cc1b3de247 unix: revert 0971598, obsoleted by 889ab21 2012-07-02 00:00:20 +02:00
Ben Noordhuis
0971598d02 unix: fix EINPROGRESS busy loop
Don't make the event loop spin when connect() returns EINPROGRESS.

Test case:

  #include "uv.h"

  static void connect_cb(uv_connect_t* req, int status) {
    // ...
  }

  int main() {
    uv_tcp_t handle;
    uv_connect_t req;
    struct sockaddr_in addr;
    addr = uv_ip4_addr("8.8.8.8", 1234); // unreachable
    uv_tcp_init(uv_default_loop(), &handle);
    uv_tcp_connect(&req, (uv_stream_t*)&handle, addr, connect_cb);
    uv_run(uv_default_loop()); // busy loops until connection times out
    return 0;
  }

After EINPROGRESS, there are zero active handles and one active request. That
in turn makes uv__poll_timeout() believe that it should merely poll, not block,
in epoll() / kqueue() / port_getn().

Sidestep that by artificially starting the handle on connect() and stopping it
again once the TCP handshake completes / is rejected / times out.

It's a slightly hacky approach because I don't want to change the ABI of the
stable branch. I'll address it properly in the master branch.
2012-06-29 19:16:40 +02:00
Ben Noordhuis
e4a68bb5cb unix: move uv__connect() to tcp.c 2012-06-29 18:21:50 +02:00
Ben Noordhuis
ddb5f55922 unix: simplify uv__make_pipe() and uv__make_socketpair() 2012-06-11 02:47:39 +02:00
Ben Noordhuis
c9396dd57e unix: implement timers in libuv
* replace libev backed timers with a pure libuv implementation
* gut ev_run() and make it take a timeout instead of flags

Incidentally speeds up the loop_count_timed benchmark by about 100%.
2012-05-31 03:08:34 +02:00
Ben Noordhuis
122cd94695 unix: remove unused flag UV__PENDING 2012-05-30 01:34:11 +02:00
Ben Noordhuis
58a272e556 unix: rework pending handle/req logic 2012-05-30 00:08:22 +02:00
Bert Belder
e4f23aacec Get rid of UV_LEAN_AND_MEAN 2012-05-28 01:53:22 +02:00
Ben Noordhuis
ce28e13038 unix: remove unused __attribute__((unused)) 2012-05-25 01:24:17 +02:00
Ben Noordhuis
752ac30ec8 unix: don't pass sockaddr to accept()
Shaves a few nanoseconds off the accept() syscall.
2012-05-24 14:31:53 +02:00
Ben Noordhuis
e71495c84a unix: turn field stream->blocking into a flag
Saves 4 bytes.
2012-05-23 22:48:57 +02:00
Ben Noordhuis
3bc9707054 unix: replace ev_io with uv__io_t
Replace ev_io usage with wrapper constructs.

This is preliminary work for the transition to a libev-less linux backend.
2012-05-23 03:42:32 +02:00
Bert Belder
c06edd4c88 windows, unix: share c-ares glue code 2012-05-22 16:11:22 +02:00
Ben Noordhuis
9efa8b3571 unix, windows: rework reference counting scheme
This commit changes how the event loop determines if it needs to stay alive.

Previously, an internal counter was increased whenever a handle got created
and decreased again when the handle was closed.

While conceptually simple, it turned out hard to work with: you often want
to keep the event loop alive only if the handle is actually doing something.
Stopped or inactive handles were a frequent source of hanging event loops.

That's why this commit changes the reference counting scheme to a model where
a handle only references the event loop when it's active. 'Active' means
different things for different handle types, e.g.:

 * timers: ticking
 * sockets: reading, writing or listening
 * processes: always active (for now, subject to change)
 * idle, check, prepare: only active when started

This commit also changes how the uv_ref() and uv_unref() functions work: they
now operate on the level of individual handles, not the whole event loop.

The Windows implementation was done by Bert Belder.
2012-05-17 07:07:53 +02:00
Bert Belder
d60d94e0c3 Unix: implement uv_poll 2012-05-03 15:52:56 +02:00
Bert Belder
e38755485e Unix: namespace stream handle flags 2012-05-03 01:47:13 +02:00
Ben Noordhuis
ab3b307df3 unix: clean up uv__req_init() 2012-04-18 22:30:20 +02:00
Ben Noordhuis
3c415975d9 unix: don't conditionally compile kqueue fs watcher
Always compile in the kqueue-based fs event watcher and handle it at run-time
if the kernel doesn't actually support it.

Works around build issues when -mmacosx-version-min is not set properly.

Fixes joyent/node#3075.
2012-04-10 23:22:32 +02:00
saghul
e3468e9d42 unix: add missing function declaration 2012-04-06 01:23:10 +02:00
Ben Noordhuis
f4e7537184 unix: move inotify init logic to loop.c 2012-04-05 15:13:14 +02:00
Ben Noordhuis
68bed698fc unix: move loop init logic out of core.c 2012-04-04 05:54:39 -07:00
Ben Noordhuis
5a8446c309 unix: move handle specific close logic out of core.c 2012-04-04 05:30:15 -07:00
Ben Noordhuis
5fbe0aab33 unix: move active checks out of core.c
Move active checks out of core.c and into their respective compilation units:
check, idle, prepare, timer.
2012-04-04 06:52:29 +02:00
Ben Noordhuis
685b36ba66 linux: tidy up syscall code 2012-03-31 00:19:01 +00:00
Ben Noordhuis
4ff0898c5f unix: replace uv__close() with close()
uv__close() was deprecated a while ago. It's been an alias for close() ever
since. Remove it.
2012-03-21 02:11:18 +01:00
Ben Noordhuis
2f886c892e unix: don't rely on libev to track timer state
An obscure libev bug sometimes makes it miss state changes. Keep track of the
state ourselves.

Fixes joyent/node#2515.
2012-02-28 17:24:50 +01:00
Ben Noordhuis
d3efefb043 linux: share inotify fd across event loop
Previously, a new inotify fd was created for each watcher, making it quite easy
to run into the system-wide fs.inotify.max_user_instances limit (usually 128).

Fixes #300.
2012-02-23 09:21:30 -08:00
Ben Noordhuis
abdc3efffe unix: add uv__dup() 2012-01-30 21:44:27 +01:00
Ben Noordhuis
cdb44df86d unix: add UNREACHABLE() macro
Asserts and aborts when program flow reaches a place it shouldn't.
2012-01-30 21:44:27 +01:00
Ben Noordhuis
28b0867f03 unix: clean up udp shutdown sequence 2012-01-18 20:18:57 +01:00
Ben Noordhuis
dee86dd5b0 unix: don't retry close() on EINTR
Linux 2.6 always closes the file descriptor, even on EINTR. Retrying the close()
call isn't merely useless, it's actively harmful - the file descriptor may have
been acquired by another thread.
2012-01-18 15:06:30 +01:00
Ryan Dahl
51ea46de45 Merge remote branch 'origin/v0.6' 2012-01-09 11:31:13 -08:00
Ben Noordhuis
803f5a096e linux: fix build on older distros 2012-01-09 15:43:00 +01:00
Ryan Dahl
3dd4ecb493 unix: expose uv__make_socketpair, uv__make_pipe in unix/internal.h 2011-12-29 22:37:33 -08:00
Ben Noordhuis
6b3075cd73 linux: improve kernel feature detection
Do not check for minimum kernel and glibc versions, just check that the kernel
headers export the syscall number and invoke the syscall directly. Effectively
bypasses glibc.
2011-12-16 15:16:31 +01:00
Ben Noordhuis
4c6008f488 Merge branch 'v0.6'
Conflicts:
	test/test-list.h
2011-12-12 18:04:17 +01:00
Shigeki Ohtsu
ba52023ef3 Fix missing increments of loop->counters 2011-12-12 18:01:26 +01:00
Ben Noordhuis
ef811b1a4f Merge branch 'v0.6' 2011-11-23 19:06:08 +01:00
Ben Noordhuis
96c230344d linux: fix build when compiling with -std=c89 -pedantic 2011-11-23 19:05:46 +01:00
Ben Noordhuis
b52b8c7128 util: add uv_strlcpy() and uv_strlcat() functions 2011-11-23 17:29:02 +01:00
Ben Noordhuis
d5b26154f7 linux: improve kernel feature detection
Do not check for minimum kernel and glibc versions, just check that the kernel
headers export the syscall number and invoke the syscall directly. Effectively
bypasses glibc.
2011-11-17 18:05:53 +01:00
Ben Noordhuis
224584c53e sunos: check that event ports supports fs watching 2011-11-10 20:04:55 +01:00
Ben Noordhuis
ec825ffc62 unix: add TCP keepalive and no-delay control knobs 2011-10-21 16:08:26 -07:00
Ben Noordhuis
721ad8c74f sunos: implement uv_fs_futime() 2011-10-12 02:05:52 +00:00
Ben Noordhuis
8e9a3384c9 unix: implement kqueue file watcher API
kqueue fds are not embeddable into other pollsets (select, poll, kqueue).
Hack the libev event loop to receive kqueue events with filter flags intact.
2011-10-04 23:28:36 +02:00
Erick Tryzelaar
23796d208c Fixes #76. Unify OS error reporting
As a nice fringe benefit, this also shaves a word
off of a windows TCP handle by replacing "uv_err_t
bind_error" with "int bind_error".
2011-09-27 19:05:33 -07:00
Ben Noordhuis
bee7112de0 unix: move container_of and SAVE_ERRNO to internal.h 2011-09-22 00:51:46 +02:00
Ben Noordhuis
2a1c32a60c linux: implement file watcher API 2011-09-21 13:23:49 -07:00
Ben Noordhuis
236b96a8cf unix: define HAVE_FUTIMES on freebsd 2011-08-17 07:01:29 +02:00
Ryan Dahl
d0a46a5551 HAVE_FUTIMES on osx 2011-09-16 16:03:48 -07:00
Ben Noordhuis
3c96410902 unix: bring back uv__stream_destroy()
This is the revised version of reverted commit 431195c.
2011-09-14 04:48:56 +02:00
Ben Noordhuis
eb987bcc5c unix: deduplicate stream init logic
Move shared init logic into uv__stream_init().
2011-09-10 01:40:47 +02:00
Ben Noordhuis
ca5346f9ce unix: revert 98b9f58 and 431195c for now, corrupts memory 2011-09-09 23:40:10 +02:00
Ben Noordhuis
431195c944 unix: run callbacks of pending writes when handle is closed 2011-09-08 19:15:22 +02:00
Ben Noordhuis
efcd273d68 unix: translate fs errno codes to libuv error codes 2011-09-06 00:17:18 +02:00
Ben Noordhuis
bb0c6e6d53 unix: move linux feature detection macros to internal.h 2011-09-05 16:05:28 +02:00
Ryan Dahl
6fd340b8ca unix: split out stream into its own file 2011-08-31 13:41:22 -07:00
Ryan Dahl
38ce213b6a unix: split out pipe 2011-08-31 13:29:17 -07:00
Ryan Dahl
510407c03d unix: split out tcp module 2011-08-31 13:11:38 -07:00
Ryan Dahl
e553f96f94 unix: split out uv_spawn into src/unix/process.c 2011-08-31 11:50:08 -07:00
Ryan Dahl
e97958ac3b unix: Split out c-ares integration into separate file 2011-08-31 11:23:29 -07:00
Ryan Dahl
58461d5ae7 split out unix's udp source 2011-08-31 11:23:29 -07:00
Ryan Dahl
e3f910d0a9 Multiplicity update on unix
Does not yet support multithreaded use of the thread pool.
2011-08-30 23:55:08 -07:00
Ryan Dahl
3be275bad7 Begin implementation of UNIX uv_fs_ functions
Adding this incomplete work now to ease rebase troubles later as it moves
the functions to src/unix/fs.c and introduces src/unix/internal.h.
2011-08-29 14:36:45 -07:00