Commit Graph

14 Commits

Author SHA1 Message Date
8ae8ccdfe0 feat: implement zero-copy splice forwarding on Linux and fix upstream connection leak
Some checks failed
Build and Test / build (push) Failing after 27s
Build and Test / coverage (push) Successful in 38s
- Add forwarding_try_splice() with Linux splice syscall for zero-copy data transfer between client and upstream sockets, reducing CPU overhead by avoiding userspace buffer copies
- Remove stale config list management in config hot reload, replacing it with direct config reference counting to simplify memory handling and eliminate potential use-after-free bugs
- Fix connection event handling to process buffered data when upstream closes, preventing data loss during connection teardown
- Close existing upstream connection before establishing new one in upstream_connect(), preventing duplicate connections for the same client
2026-01-27 19:53:29 +00:00
6783b80844 chore: add retoor attribution and expand source file list in Makefile
- Add author comment with retoor <retoor@molodetz.nl> at top of Makefile
- Include 12 new source files (config_parser, http_response, client_handler, upstream, forwarding, base64, socket_utils, epoll_utils, time_utils, histogram, deque, rate_tracker, stats_collector) to SOURCES and TEST_LIB_SOURCES
- Add corresponding backup copies of auth.c, config.c, connection.c, and monitor.c to src/backup/ directory
2026-01-27 19:34:43 +00:00
ab70643e1f feat: reject HTTP pipelined requests with 400 error and close upstream connection
Add detection of pipelined requests in handle_client_read by checking if buffered data starts with a new HTTP request. When a pipelined request is detected, the server now sends a 400 Bad Request response with a descriptive body, closes the upstream connection, and transitions the client state to CLIENT_STATE_CLOSING. Previously, the server would silently close the upstream connection and continue reading headers. The change also includes a comprehensive test that validates the rejection behavior, response content, and connection state transitions for pipelined requests.
2026-01-27 16:15:20 +00:00
69ab2f4fd9 feat: process buffered client data after upstream connection closes to prevent data loss
Add logic in connection_close to detect remaining buffered data on client read buffer when an upstream connection is closed, and invoke handle_client_read to process it. Also add a forward declaration for handle_client_read and include debug logging for routing decisions. A new test validates that pipelined requests buffered before upstream close are correctly handled.
2026-01-27 15:19:36 +00:00
f75581963a chore: add http_uri_is_internal_route and http_normalize_uri_path with tests for internal routing 2026-01-06 14:12:10 +00:00
a4438c6b60 chore: remove unused stdio.h include from main.c and fix typo in comment 2026-01-01 20:55:23 +00:00
0eac08394c feat: enable keep-alive for internal routes by resetting connection state and handling pending reads
Reset multiple connection flags (content_type_checked, is_textual_content, response_headers_parsed, original_content_length, content_length_delta, patch_blocked) when reusing connection for internal route keep-alive. Add immediate handling of any buffered read data after state reset to prevent stale data blocking subsequent requests. Add comprehensive test verifying second request processing on internal dashboard route via Unix socket pair.
2025-12-29 01:22:20 +00:00
45005f904b feat: add formatNum and formatMs helpers for dashboard metric display 2025-12-29 00:50:08 +00:00
598668ca8a feat: integrate monitoring metrics into connection handling and redesign dashboard with advanced charts
Add real-time tracking of accepted connections, upstream connection success/failure, DNS errors, and retries to connection.c. Introduce histogram, rate tracker, and health score data structures in types.h and monitor.h/c. Redesign dashboard HTML/CSS with color-coded health metrics, responsive charts grid, and tall chart containers for improved visualization of system performance data.
2025-12-29 00:37:24 +00:00
ca8bdcf2cd feat: add constant-time credential comparison, rate limiting, SSL hostname verification, and update coverage threshold to 69% 2025-12-28 04:16:15 +00:00
155df9ad3e chore: add test_logging.c to build system and raise minimum coverage threshold from 60 to 69 2025-12-15 01:36:54 +00:00
353e6b08b6 feat: add TCP_NODELAY socket optimization and upstream handling with connection caching tests 2025-12-15 00:31:27 +00:00
9e7c5940dc perf: cache epoll events in connection struct and add socket optimization routines 2025-12-15 00:28:34 +00:00
c84d8c9d21 feat: add splice pipe fields and patch buffer to connection struct for zero-copy forwarding 2025-12-15 00:12:09 +00:00