Commit Graph

17 Commits

Author SHA1 Message Date
Ben Noordhuis
82f025e036 src: replace ngx_queue_split with ngx_queue_move
All uses of ngx_queue_split in libuv split the list at the head so
introduce a ngx_queue_move macro that automates that.

This is a backport of commit 1867a6c from the v1.x branch.

PR-URL: https://github.com/libuv/libuv/pull/566
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-10-12 01:54:02 +02:00
Ben Noordhuis
8fbe43379d unix: please valgrind, free memory in threadpool.c 2013-03-07 01:57:30 +01:00
Ben Noordhuis
1e97b4567e unix: honor UV_THREADPOOL_SIZE environment var
Make the size of the thread pool configurable through an environment
variable. For sanity reasons, the size is clamped to the range 1-128.
2013-03-06 23:19:34 +01:00
Ben Noordhuis
35b159a83e unix: make uv__work_cancel() static 2013-01-06 21:25:58 +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
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
Ben Noordhuis
52c8a8617d unix: add uv_cancel() 2012-12-09 15:12:42 +01:00
Ben Noordhuis
99a8d4a8c2 unix: remove unnecessary static var init
wq doesn't have to be initialized, init_once() takes care of that.

Remove the initialization so it goes into .bss instead of .data.
2012-11-29 16:54:09 +01:00
Ben Noordhuis
2be240d3cd unix: initialize thread pool mutex and condvar
It accidentally worked before this commit on Linux but not on OS X.

Fixes #637.
2012-11-29 15:34:35 +01:00
Ben Noordhuis
99d3102b90 unix: drop pthread dependency in threadpool.c
Replace the pthread code with their libuv counterparts. One step closer to a
shared thread pool implementation.
2012-11-26 02:08:54 +01:00
Shigeki Ohtsu
0cca5391ba unix, windows: disallow NULL worker in thread pool
See #629.
2012-11-24 01:09:49 +01:00
Ben Noordhuis
dcd3b55c19 unix: fix thread pool race condition
Send the wakeup signal to the main thread *before* releasing the lock. Doing it
the other way around introduces a race condition where the watcher may already
have been pulled off the work queue.
2012-11-22 15:01:17 +01:00
Ben Noordhuis
4affbe70b6 unix: remove unnecessary pthread_join ESRCH check
ESRCH means the thread never got started but we guard against that now.
2012-10-10 01:11:09 +02:00
Ben Noordhuis
40134c3537 unix: don't reap threads if none were started
Fixes a segmentation fault on 32 bits linux with glibc 2.15.

Thanks to Johan Bergström (@jbergstroem) for reporting the issue and testing
out the patch.
2012-10-08 00:37:03 +02:00
Ben Noordhuis
b9ed1a6dbf unix: don't abort() on EINVAL in threadpool.c
The FreeBSD implementation of pthread_join() returns EINVAL when a thread has
already quit, not ESRCH.
2012-10-06 22:58:28 +02:00
Artur Adib
fed718c6cb unix: move queue stuff from fs.c to threadpool.c 2012-10-03 23:56:01 +02:00
Ben Noordhuis
f35a4b628a unix: add custom thread pool 2012-10-01 22:53:59 +02:00