Commit Graph

2020 Commits

Author SHA1 Message Date
Ben Noordhuis
ccb96b67df test: remove unused function declaration 2013-01-06 22:31:48 +01:00
Ben Noordhuis
847182cdf1 test, bench: make functions/variables static
Make functions and variables that are local to the compilation unit
static. Remove what turns out to be unused.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
7ff6f29b85 test, bench: ANSI-fy function prototypes
Replace `void f()` with `void f(void)`; the former means "a function
that takes any number of arguments, including none" while the latter
is what is actually intended: a function taking no arguments.

The first form also isn't strictly conforming ANSI/ISO C.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
fa9c577e55 linux: fix race in uv_resident_set_memory()
uv_resident_set_memory() used a global buffer to read data into, which
is a decidedly unsafe thing to do in a multi-threaded environment.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
5b63285805 unix, windows: ANSI-fy uv_tty_reset_mode() prototype 2013-01-06 22:31:47 +01:00
Ben Noordhuis
edd10071eb unix: fix up #if defined checks
`#if FOO` (where FOO is undefined) is a legal construct in C89 and C99
but gcc, clang and sparse complain loudly about it at higher warning
levels.

Squelch those warnings. Makes the code more consistent as well.
2013-01-06 22:31:47 +01:00
Ben Noordhuis
e62dd3caa0 unix: fix include in cygwin.c 2013-01-06 21:25:58 +01:00
Ben Noordhuis
a2bedc0a7e unix: make uv__read_start_common() static 2013-01-06 21:25:58 +01:00
Ben Noordhuis
35b159a83e unix: make uv__work_cancel() static 2013-01-06 21:25:58 +01:00
Ben Noordhuis
0a06c2f3b2 unix: fix up function prototypes in signal.c 2013-01-06 21:25:58 +01:00
Ben Noordhuis
87cbf8d0c2 unix: remove unused function uv__strlcpy() 2013-01-06 21:25:58 +01:00
Ben Noordhuis
345eb6394f unix: add checksparse.sh script 2013-01-06 21:25:58 +01:00
Ben Noordhuis
1f52fc1c5a test: remove consumer_producer test
It fails intermittently on Travis for no other reason than that Travis
is occasionally slow. Reduce the number of false positives, remove the
test.
2013-01-06 19:19:23 +01:00
Ben Noordhuis
2f55353490 unix: update loop->time after poll
Fixes a bug where timers expire prematurely when the following
conditions hold:

  a) libuv first spends some time blocked in the platform poll function
  b) a callback then calls uv_timer_start()

Cause: uv_timer_start() uses an out-of-date loop->time in its
'when should the timer callback run?' calculations.

Solution: Update loop->time before invoking any callbacks.

Fixes #678.
2013-01-06 18:30:03 +01:00
Ben Noordhuis
339033afc0 unix: use uv__hrtime() internally
This commit renames the various uv_hrtime() implementations to uv__hrtime().

Libuv uses the high-res timer internally in performance-critical code paths.
Calling the non-public version avoids going through the PLT when libuv is
compiled as a shared object.

The exported uv_hrtime() now has a single definition in src/unix/core.c that
calls uv__hrtime().

A future optimization is to lift the uv__hrtime() declarations into header
files so they can be inlined at the call sites. Then again, linking with -flto
should accomplish the same thing.
2013-01-06 17:35:34 +01:00
Fedor Indutny
ba83510fc0 stream: fix infinite select() polling on osx
Interruption FD buffer should be emptied after write, otherwise select()
loop will poll indefinitely.
2013-01-04 21:10:33 +04:00
Ben Noordhuis
775f2c1f53 unix: remove stale closing check in uv__write()
Introduced in 0db3274f but no longer necessary; uv__write() no longer
runs when the handle has been closed. Write callbacks receive a special
status code that informs them that the handle has been closed.
2013-01-02 18:05:32 +01:00
Ben Noordhuis
a657e7f576 unix: remove uv_write_queue_head() 2013-01-02 17:45:37 +01:00
Ben Noordhuis
0b3ab72579 unix: remove bogus uv__write() comment 2013-01-02 17:15:54 +01:00
Ben Noordhuis
546387fc47 include: add note about SIGRT0 and SIGRT1 on linux 2012-12-28 22:17:51 +01:00
Ben Noordhuis
92a19a19dd unix: ensure done_cb gets called after uv_cancel()
Wake up the event loop with uv_async_send() when a request is cancelled.
Ensures the done_cb is run on the next tick of the event loop.

Not sending a wakeup signal results in the done_cb not getting called until
another request completes, which may be a long time coming when it's the only
request in the queue or when other requests are executing long-running jobs.

Fixes #669.
2012-12-28 18:09:39 +01:00
Saúl Ibarra Corretgé
9614d51135 unix: reset errno when using sendfile emulation
A common way to check if a uv_fs_t request failed is to check that
req->errorno != 0.

With uv_fs_sendfile(), when the sendfile() syscall fails, req->errorno is set
to (for example) ENOTSOCK, even when the emulation code path succeeds.

Zero errno before the call to uv__fs_sendfile_emul() to prevent that from
happening.
2012-12-28 16:00:49 +01:00
Ben Noordhuis
69ab328d9f sunos: fix !defined(PORT_SOURCE_FILE) build 2012-12-28 12:45:47 +01:00
Ben Noordhuis
3164f1ea69 include: update uv_signal_t doc comments
Fixes #668.
2012-12-25 21:51:19 +01:00
Ben Noordhuis
495ac83402 build: export _DARWIN_C_SOURCE to dependents
Exporting just _POSIX_C_SOURCE=200112 hides SysV / BSD definitions like
S_IREAD and S_IWRITE. Exporting _DARWIN_C_SOURCE fixes that.

Issue reported by Travis Tilley.
2012-12-24 23:38:52 +01:00
Saúl Ibarra Corretgé
4650a5971b unix: don't run loop when all handles are unref'd 2012-12-24 17:05:52 +01:00
Saúl Ibarra Corretgé
33d5c497a6 prepare/idle/check: don't allow NULL callback 2012-12-24 17:05:01 +01:00
Ben Noordhuis
5af43ba446 bench: add 'million async handles' benchmark 2012-12-24 12:19:10 +01:00
Ben Noordhuis
1c722d6c22 test: make fmt() not leak memory 2012-12-24 12:03:25 +01:00
Vlad Tudose
4b115f89bf build: build libuv.a and libuv.so in different dirs
Fixes #659.
2012-12-19 15:34:19 +01:00
Ben Noordhuis
6fb31493d7 build: export _POSIX_C_SOURCE=200112 to dependents
Fix direct_dependent_settings to export _POSIX_C_SOURCE=200112 to dependent
projects. Required to make pthread_rwlock_t and pthread_barrier_t visible.
2012-12-19 15:34:19 +01:00
Saúl Ibarra Corretgé
0820be7008 Implemented uv_run2
Allows for running the event loop in 3 modes:
  * default: loop runs until the refcount drops to zero
  * once: poll for events only once and block until one is handled
  * nowait: poll for events only once but don't block if there are
    no pending events
2012-12-18 16:11:23 +01:00
Ben Noordhuis
dc559a5ce6 unix: disable relaxed accept() by default
Don't use the relaxed accept() algorithm introduced in be2a217 unless
explicitly requested. It causes a 50+% performance drop on some node.js
benchmarks:

  $ alias bench='out/Release/node benchmark/http_simple_auto.js \
    -c 10 -n 50000 bytes/1 2>&1 | grep Req'

  $ UV_TCP_SINGLE_ACCEPT=0 bench
  Requests per second:    12331.84 [#/sec] (mean)

  $ UV_TCP_SINGLE_ACCEPT=1 bench
  Requests per second:    3944.63 [#/sec] (mean)
2012-12-18 15:44:21 +01:00
Fedor Indutny
b86ed94940 kqueue: ignore ENOENT error
File descriptor might be closed during callback, all events that was reported
before the callback are not valid and trying to remove them will result
in ENOENT. This error can be safely ignored.
2012-12-18 13:48:46 +04:00
Ben Noordhuis
273cecc56f unix: don't memset(0) in uv_udp_init()
It's inconsistent with other init functions. In particular, it clobbers the
data field.

Fixes #655.
2012-12-15 21:14:39 +01:00
Ben Noordhuis
c6c5b7a901 Merge branch 'v0.8' 2012-12-14 12:07:31 +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
Ben Noordhuis
a3b57dd598 test, bench: remove unused includes 2012-12-14 11:48:04 +01:00
Ben Noordhuis
f5b6374948 test, bench: replace strlen() with sizeof() 2012-12-14 11:47:54 +01:00
Ben Noordhuis
0a05b31a93 test: fix -Wunused-result warnings 2012-12-14 11:34:17 +01:00
Ben Noordhuis
e079a99abd unix: fix event loop stall
Fix a rather obscure bug where the event loop stalls when an I/O watcher is
stopped while an artificial event, generated with uv__io_feed(), is pending.
2012-12-13 20:17:12 +01:00
Ben Noordhuis
92fb84b751 unix: rework uv_cancel() api
Bert Belder informs me the current approach where a request is immediately
cancelled, is impossible to implement on Windows.

Rework the API to always invoke the "done" callback with an UV_ECANCELED error
code.
2012-12-13 13:46:38 +01:00
Fedor Indutny
731adacad2 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-12-09 15:43:08 +01:00
Ben Noordhuis
52c8a8617d unix: add uv_cancel() 2012-12-09 15:12:42 +01:00
Ben Noordhuis
a385ae4f59 unix: only set SO_REUSEADDR on tcp listen sockets
Avoid the extra syscall, it's a no-op for non-listening sockets.

At least, it should be - it remains to be investigated if a FreeBSD kernel bug
affects ephemeral port allocation inside connect(). See [1] for details.

[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=174087
2012-12-09 14:34:33 +01:00
Ben Noordhuis
b4168cd697 build: rename LINKFLAGS to LDFLAGS 2012-12-08 08:06:12 +01:00
Ben Noordhuis
7306c5ff46 build: fix make libuv.so CFLAGS=<options>
Running a make target that builds the shared object while overriding the CFLAGS
variable from the command line, would fail with a relocation error:

   relocation R_X86_64_32 against `.text' can not be used when making a shared
   object; recompile with -fPIC

Fix that by adding -fPIC unconditionally.
2012-12-08 08:04:08 +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
Bert Belder
2e4488f35a 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:04:37 +01:00