Open arghness opened 1 year ago
The same problem like you i used the API Routes::Remove but i still access to the server after removing routes in many use case the application crash due an issue of bind ...
The same problem like you i used the API Routes::Remove but i still access to the server after removing routes in many use case the application crash due an issue of bind ...
I'm pretty sure that's still not thread safe, it still just calls the methods on Router / Private::RouterHandler, so you'll run in to issues unless you're very careful.
I'm not entirely sure if my wrappers are fully thread-safe, but they seem okay so far.
I've not looked at the code, but I suspect that you are correct. Adding and removing routes is likely not thread safe; it should take a writer lock on the routing table, and doing route lookups should take a reader lock. This locking is likely non-existent.
You can probably verify this with valgrind --fair-sched=yes ${your_program}
.
I started writing a thread-safe wrapper for Router / Private::RouterHandler to support adding and removing routes dynamically, when I saw in the RouterHandler comments:
I wondered how this might be done safely, once the server is running? Can it only be done when processing a request on a single-threaded server?