Skip to content

Conversation

@etr
Copy link
Owner

@etr etr commented Jan 27, 2026

Supersedes #330

Description

This PR introduces mutex protection for webserver member variables to prevent data races (fixes #329).

Changes

  • Add std::shared_mutex for registered_resources, bans, and allowances
  • Use shared_lock for read operations, unique_lock for write operations
  • Make appropriate member variables const (single_resource, tcp_nodelay, error handler pointers)
  • Simplify policy_callback condition for better readability
  • Add thread safety stress test

Credit

Original work by @FlorianChevassu - rebased onto master to resolve conflicts and pick up CI fixes.

Co-authored-by: Florian CHEVASSU fchevassu@antidot.net

@etr etr mentioned this pull request Jan 27, 2026
- Move opening brace to end of line in policy_callback
- Replace using-directive with using-declaration for chrono_literals
- Use static_cast instead of C-style cast
- Use rand_r instead of rand for thread safety
@etr etr merged commit 57522ba into master Jan 27, 2026
36 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Data races

3 participants