|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
Panic recovery middleware implementation. More...
#include <setjmp.h>#include <stdio.h>#include <stdlib.h>#include "context_internal.h"#include "csilk/core/internal.h"#include "csilk/csilk.h"
Functions | |
| void | csilk_recovery_handler (csilk_ctx_t *c) |
| Panic recovery middleware — catches longjmp panics and returns 500. | |
| void | csilk_panic (csilk_ctx_t *c) |
| Trigger a panic (longjmp to recovery handler) or abort if no recovery registered. | |
Panic recovery middleware implementation.
| void csilk_panic | ( | csilk_ctx_t * | c | ) |
Trigger a panic (longjmp to recovery handler) or abort if no recovery registered.
Trigger a panic (caught by recovery middleware).
If a recovery handler has been installed (c->has_jump_buffer is set), this function performs a longjmp back to the recovery point set by csilk_recovery_handler().
If no recovery handler is registered, it prints a fatal error message to stderr and calls exit(1) to terminate the process.
| c | The request context. May be NULL (will trigger abort path). |
| void csilk_recovery_handler | ( | csilk_ctx_t * | c | ) |
Panic recovery middleware — catches longjmp panics and returns 500.
Panic-recovery middleware.
Installs a setjmp recovery point before calling csilk_next(). If any downstream handler triggers csilk_panic(), execution resumes at the setjmp point and an "Internal Server Error" response (500) is sent instead of crashing the process.
After the normal (non-panic) path completes, the jump buffer flag is cleared.
| c | The request context (must have a valid jump_buffer). |