trantor icon indicating copy to clipboard operation
trantor copied to clipboard

Make trantor::Logger::setOutputFunction thread safe

Open Demilivor opened this issue 11 months ago • 0 comments

The call to the trantor::Logger::setOutputFunction is not thread safe: https://github.com/an-tao/trantor/blob/8bf280ba043eb77c3eb02121065e0891a9a4f431/trantor/utils/Logger.h#L124-L139

2 threads can simultaneously set the values, or at least 1 simulaneous reader can read the value during the change of output function.

Proposal solution: Use std::shared_mutex here. Use exclusive lock during modification and shared lock during the reading. This sure will consume some performance, but at least will be thread-safe.

Demilivor avatar Dec 17 '24 23:12 Demilivor