summaryrefslogtreecommitdiff
path: root/src/common/workqueue.c
AgeCommit message (Collapse)Author
2018-07-05All remaining files in src/common belong to the event loop.Nick Mathewson
2018-06-29Remove util.h and compat.h includes from src/commonNick Mathewson
2018-06-29Remove non-windows system includes from compat.h and util.hNick Mathewson
2018-06-28Move weakrng into lib/intmathNick Mathewson
2018-06-28Extract threading code into a new library.Nick Mathewson
Note that the workqueue code does *not* go here: it is logically at a higher level, since it needs to use libevent and the networking stack.
2018-06-28Extract the alert-socket code into lib/net.Nick Mathewson
This code was in compat_threads, since it was _used_ for efficiently notifying the main libevent thread from another thread. But in spite of its usage, it's fundamentally a part of the network code.
2018-06-22Automated fixup of include paths after torlog.h movement.Nick Mathewson
2018-06-21Rectify include paths (automated)Nick Mathewson
2018-06-20Run rectify_include_paths.pyNick Mathewson
2018-05-03Merge remote-tracking branch 'isis/bug24660_r1'Nick Mathewson
2018-04-06crypto: Refactor (P)RNG functionality into new crypto_rand module.Isis Lovecruft
* ADD new /src/common/crypto_rand.[ch] module. * ADD new /src/common/crypto_util.[ch] module (contains the memwipe() function, since all crypto_* modules need this). * FIXES part of #24658: https://bugs.torproject.org/24658
2018-04-05Move responsibility for threadpool reply-handler events to workqueueNick Mathewson
This change makes cpuworker and test_workqueue no longer need to include event2/event.h. Now workqueue.c needs to include it, but that is at least somewhat logical here.
2017-12-08Convert remaining function (mostly static) to new free styleNick Mathewson
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.