aboutsummaryrefslogtreecommitdiff
path: root/src/common/workqueue.c
AgeCommit message (Collapse)Author
2017-07-27Try to work around a compile warning in workqueue.cNick Mathewson
2017-07-27Note that threadpool_queue_work...() can't actually return NULLNick Mathewson
2017-07-27Fix a pair of stale comments in workqueue.cNick Mathewson
These comments said that each thread had a separate queue, but we haven't been using that design for some while.
2017-07-27Make the chance for priority inversion thread-specificNick Mathewson
Instead of choosing a lower-priority job with a 1/37 chance, have the chance be 1/37 for half the threads, and 1/2147483647 for the other half. This way if there are very slow jobs of low priority, they shouldn't be able to grab all the threads when there is better work to do.
2017-07-27Add support for multi-priority workqueuesNick Mathewson
Each piece of queued work now has an associated priority value; each priority goes on a separate queue. With probability (N-1)/N, the workers will take work from the highest priority nonempty queue. Otherwise, they'll look for work in a queue of lower priority. This behavior is meant to prevent starvation for lower-priority tasks.
2017-03-15Correctly handle fd-drain errors on windows workqueuesNick Mathewson
Windows doesn't let you check the socket error for a socket with WSAGetLastError() and getsockopt(SO_ERROR). But getsockopt(SO_ERROR) clears the error on the socket, so you can't call it more than once per error. When we introduced recv_ni to help drain alert sockets, back in 0.2.6.3-alpha, we had the failure path for recv_ni call getsockopt() twice, though: once to check for EINTR and one to check for EAGAIN. Of course, we never got the eagain, so we treated it as an error, and warned about: "No error". The fix here is to have these functions return -errno on failure. Fixes bug 21540; bugfix on 0.2.6.3-alpha.
2016-10-17Write a bunch of module documentation.Nick Mathewson
This commit adds or improves the module-level documenation for: buffers.c circuitstats.c command.c connection_edge.c control.c cpuworker.c crypto_curve25519.c crypto_curve25519.h crypto_ed25519.c crypto_format.c dircollate.c dirserv.c dns.c dns_structs.h fp_pair.c geoip.c hibernate.c keypin.c ntmain.c onion.c onion_fast.c onion_ntor.c onion_tap.c periodic.c protover.c protover.h reasons.c rephist.c replaycache.c routerlist.c routerparse.c routerset.c statefile.c status.c tor_main.c workqueue.c In particular, I've tried to explain (for each documented module) what each module does, what's in it, what the big idea is, why it belongs in Tor, and who calls it. In a few cases, I've added TODO notes about refactoring opportunities. I've also renamed an argument, and fixed a few DOCDOC comments.
2016-06-08Mark the unreachable lines in compat_{,p}threads and workqueueNick Mathewson
These are all related to failures from functions that either can't fail as we call them, or where we cannot provoke failure.
2016-02-27Add a brief file-level description for everything in src/commonNick Mathewson
2015-08-21Ensure worker threads actually exit when it is timeSebastian Hahn
This includes a small refactoring to use a new enum (workqueue_reply_t) for the return values instead of just ints.
2015-08-17Merge remote-tracking branch 'public/bug16741_026'Nick Mathewson
2015-08-07Check for EINTR correctly on windowsNick Mathewson
(even though these are nonblocking calls and EINTR shouldn't be possible). Also, log what error we're seing if drain_fn fails.
2015-08-04Switch order of unblocking threads and releasing the mutex.cypherpunks
According to POSIX, the mutex must be locked by the thread calling the signal functions to ensure predictable scheduling behavior. Found the issue using Helgrind which gave the warning `dubious: associated lock is not held by any thread`.
2015-07-21Fix some potential memory leaks in the thread pool code.cypherpunks
2015-05-28Impose an upper limit on threads per threadpool.Nick Mathewson
Found by Coverity; Fixes CID 1268069
2015-02-17Check thread count for negative; realloc->reallocarrayNick Mathewson
CID 1268069
2015-02-16Fix a few coverity "Use after NULL check" warningsNick Mathewson
Also remove the unit test mocks that allowed get_options() to be NULL; that's an invariant violation for get_options().
2015-02-15Don't leak a cond var when starting threads in a poolSebastian Hahn
2015-01-21use the correct free fn. spotted by dgouletNick Mathewson
2015-01-21Fix up some workqueue/threading issues spotted by dgoulet.Nick Mathewson
2015-01-15Update workqueue implementation to use a single queue for the workNick Mathewson
Previously I used one queue per worker; now I use one queue for everyone. The "broadcast" code is gone, replaced with an idempotent 'update' operation.
2015-01-14Incorporate some comments based on notes from dgouletNick Mathewson
2015-01-14Refactor cpuworker to use workqueue/threadpool code.Nick Mathewson
2015-01-14Test and fix workqueue_entry_cancel().Nick Mathewson
2015-01-14Test a little more of compat_threads.cNick Mathewson
2015-01-14Documentation for new workqueue and condition and locking stuffNick Mathewson
2015-01-14Add a way to tell all threads to do something.Nick Mathewson
2015-01-14Isolate the "socketpair or a pipe" logic for alerting main threadNick Mathewson
This way we can use the linux eventfd extension where available. Using EVFILT_USER on the BSDs will be a teeny bit trickier, and will require libevent hacking.
2015-01-14Make pending work cancellable.Nick Mathewson
2015-01-14Initial workqueue implemention, with a simple test.Nick Mathewson
It seems to be working, but more tuning is needed.