about summary refs log tree commit homepage
path: root/queue_epoll.c
DateCommit message (Collapse)
2020-01-18s/bogomips.org/yhbt.net/, update copyrights for 2020
bogomips.org is due to expire, soon, and I'm not willing to pay extortionist fees to Ethos Capital/PIR/ICANN to keep a .org. So it's at yhbt.net, for now, but it will change again to whatever's affordable... Identity is overrated. Tor users can use .onions and kick ICANN to the curb: torsocks w3m http://cmogstored.ou63pmih66umazou.onion/ torsocks git clone http://ou63pmih66umazou.onion/cmogstored.git/ torsocks w3m http://ou63pmih66umazou.onion/cmogstored-public/
2018-11-28update copyrights for 2018 and use SPDX for "GPL-3.0+"
copyrights updated by "update-copyright" in gnulib: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright While we're at it, SPDX seems to be the accepted way to identify licenses nowadays, so lets use it. git ls-files | xargs perl -i -p -e \ 's,GPLv3 or later.*,GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>,g'
2016-05-29update copyrights for 2016
git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright
2015-03-06copyright updates for 2015
Via update-copyright in gnulib, also added a few copyrights to non-trivial files. git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright
2014-11-02update copyrights to 2014 (and all contributors)
In the future, we can use the update-copyright tool from gnulib: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright This project (nor any project I manage) has or ever will have have copyright assignment. All contributors retain copyrights to their contributions.
2014-09-05queue_epoll: disable buggy epoll workaround for 2.6.34.15+
commit 356ad39592cfcb537a512b2f88ed44380ae5cd78 ("epoll: prevent missed events on EPOLL_CTL_MOD") in the 2.6.34 stable tree
2013-07-16queue_epoll: EPOLL_CTL_MOD should be safe on 2.6.32.61+
Willy Tarreau cherry-picked the relevant fix into 2.6.32 longterm stable tree ref: commit 1c137a47bbdd6e86298627e04f547afd7f35d523 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
2013-06-25avoid leaks on epoll/kqueue resources exhaustion
Simply releasing the descriptor triggering ENOSPC/ENOMEM errors from epoll_ctl and kevent is not good enough, as those descriptors may have other descriptors (e.g. files to be served) hanging off of them.
2013-06-25replace pthreads cancellation with explicit checks
Due to data/event loss, we cannot rely on normal syscalls (accept/epoll_wait) being cancellation points. The benefits of using a standardized API to terminate threads asynchronously are lost when toggling cancellation flags. This implementation allows us to be more explicit and obvious at the few points where our worker threads may exit and reduces the amount of code we have. By avoiding the calls to pthread_setcancelstate, we should halve the number of atomic operations required in the common case (where the thread is not marked for termination).
2013-06-25do not rely on normal syscalls as cancellation points
Cancellation with epoll_wait, accept4 (and accept) may cause events to be lost, as cancellation relies on signals anyways in glibc/Linux. So instead, we use signaling ourselves and explicitly test for cancellation only if we know we are interrupted and in a state where a thread can safely be cancelled. ref: http://mid.gmane.org/CAE2sS1gxQkqmcywQ07pmgNHM+CyqzMkuASVjmWDL+hgaTMURWQ@mail.gmail.com
2013-06-25avoid needlessly reinitializing common sigset_t
This should hopefully save a few cycles and reduce stack usage slightly.
2013-02-18queue_epoll: fix bad cast for epoll.event
The events field of struct epoll_event is a uint32_t, not int.
2013-02-14selfwake: use epoll_pwait on Linux instead of eventfd
This saves us a file descriptor in Linux, which provides epoll_pwait in 2.6.19+ (and ppoll for 2.6.18, the oldest kernel we support).
2013-02-06queue_epoll: change fprintf(stderr, ...) to use warn()
This makes it easier alter how/if we write to stderr.
2013-01-17queue_epoll: fix version check for 2.x kernels v1.1.0
Oops, we could accidentally mark a 2.x kernel as non-buggy. 2.6.32 and 2.6.34 may eventually get backports.
2013-01-17copyright comment updates for 2013
gnulib did it for us in m4/gnulib-cache.m4, we'll match.
2013-01-17epoll: update EPOLL_CTL_MOD workaround for stable kernels
Linux v3.2.37+ does not need this fix. Linux v3.0.59+, v3.4.26+, v3.5.7.3+, v3.7.3+ are all under review and not need this.
2013-01-02epoll: avoid EPOLL_CTL_MOD bug in Linux <= 3.7.1
On SMP machines, EPOLL_CTL_MOD had a race condition under Linux <= 3.7.1. This allowed events to be missed if it arrived near the time the EPOLL_CTL_MOD request was issued. ref: linux.git commit 128dd1759d96ad36c379240f8b9463e8acfd37a1
2012-12-09remove queue_state field from struct mog_fd
We do not need to track queue state any longer since accept threads always inject directly into the epoll/kqueue watcher nowadays.
2012-12-05cleanup and simplify interrupt/shutdown handling
We now assume any non-zero timeout (not just infinite timeout) is cancellable as well as interruptible. This means mog_idleq_wait will no longer retry blindly on EINTR. Handling of explicit device refreshes and aio_threads is now easier-to-understand and follow.
2012-11-08queue: refactor for future, potential kqueue speedup
kevent() has the ability to insert items into the kqueue and retrieve with the same syscall. This allows us to reduce syscalls on systems with kqueue support. Regardless of whether this potential optimization can improve performance, this makes the code smaller and possibly easier to follow.
2012-10-30die() using error() from glibc/gnulib
Compared to our previous function, this: * prefixes the message with the program name * can show the strerror() message more consistently * automatically adds a trailing newline for us
2012-07-12remove user-space, SIMPLEQ-based active queue
Epoll/kqueue descriptors are safely usable for this task given the the ability to use one-shot notifications (which is independent of level-triggering, even).
2012-04-22fix spelling of "cancellable"
"cancellation" has a double-L, so "cancellable" should be spelled with two Ls, too..
2012-04-21cleanup error handling for rare errors
EBADF is majorly bad news for threaded apps like this one and indicative of a fatal bug, so be sure we enforce it so it never happens. We also never close file kqueue or epoll file descriptors, so EBADF should really never happen. ENOMEM from epoll_ctl() should be recoverable by falling back to the active queue.
2012-04-21queue: rework kevent cancellation handling
The kevent() function as implemented by libkqueue does not support thread cancellation the same way a real kevent() (on FreeBSD) appears to. So pretend no implementation of kevent() is cancelable and handle cancellation ourselves using pthread_testcancel(). This allows us to support any platform where kevent() may work, since it's unclear if other *BSDs implement kevent() as a cancellation point.
2012-02-23avoid scanning the entire fd_map for queues at shutdown
Eventually we may benefit from multiple queues and configurable queue counts, so just use some of the dead space for storing all queues in a linked-list.
2012-02-22queue: allow configurable timeout
It looks like we'll want to be able to sleep an interval that's not "forever". We can replace select() in the main loop with epoll/kqueue to simplify our (eventual) graceful shutdown logic.
2012-02-22queue_loop: simplify blocking wait wakeup logic
We use thread cancellation to shut down our queue processing threads so we don't have to rely on signals or cross-thread close() + EBADF from an epoll/kqueue descriptor to know our queue is due for shutdown.
2012-01-11initial commit
Nuked old history since it was missing copyright/GPLv3 notices.