mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Fibers: stacks a thread switches to and back
src/fiber.c, not used yet: a fiber runs a function on a stack of its own, yielding back to the thread which resumed it, for a thread to serve many clients with code written as if each had a thread. The switch is our own on x86-64 (System V), aarch64, i386, arm (ARM or Thumb code, with or without a floating point unit) and mips o32 (with soft, 32 or 64 bit floating point registers, position independent or not), Windows' fibers on Windows. It saves the registers a function has to keep and swaps the stack. Elsewhere there are no fibers (WITH_FIBERS is not defined), nor where x86-64 Linux checks returns against a shadow stack, which fiberusable() tells: each client has a thread there. Stacks are mapped with a guard page below them. A fiber whose function returned is started again with another, its stack kept. Switches are annotated for AddressSanitizer. tests/fibertest.c tests them: yielding and resuming, the integer and floating point registers a function keeps across switches both ways, a thousand fibers resumed at random each keeping its stack, recursion deep in a stack, fibers sleeping on the event loop's timers. The units case, which was the loop case, runs it with looptest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc98c498fe
commit
4e1455b419
8 files changed
+910
-42
No files matched your search
+7
-4
@@ -68,10 +68,13 @@ Note that access rules accumulate until `flush`, so a service section that
|
||||
means to stand on its own should start with one - otherwise an earlier
|
||||
`allow *` matches first and the rule under test is never reached.
|
||||
|
||||
The event loop (`src/loop.c`) is tested on its own by `tests/looptest.c`,
|
||||
which CMake builds next to the 3proxy binary and the `loop` case runs: timers
|
||||
on a clock of its own, through several turns of the wheel, sockets, and
|
||||
other threads. Where it was not built the case is skipped.
|
||||
The event loop (`src/loop.c`) and fibers (`src/fiber.c`) are tested on their
|
||||
own by `tests/looptest.c` and `tests/fibertest.c`, which CMake builds next to
|
||||
the 3proxy binary and the `units` case runs: timers on a clock of their own,
|
||||
through several turns of the wheel, sockets, other threads; fibers yielding
|
||||
and resumed, the registers a function keeps, a thousand stacks, fibers
|
||||
waiting on the loop's timers. Where they were not built the case is
|
||||
skipped.
|
||||
|
||||
## What is not covered yet
|
||||
|
||||
|
||||
Reference in new issue
Block a user