Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Recorder]: Acquire lock for ofstream changes (#1145)
While the Recorder is writing to the sairedis log file, it's possible for a log rotate to occur at exactly the right time so that file stream used for writing (a std::ofstream) is re-opened in the middle of the write operation (since writing and log rotate are handled by separate threads). Since standard library objects are not thread safe, this can cause some pointers used during the write operation to be overwritten, leading to a segmentation fault when the write operation proceeds. To prevent this from occurring, acquire a lock for the file stream for any methods that change the ofstream (including opening, closing, and writing to it with the << operator). Also use recordLine for all writes to the file stream to avoid deadlock. Signed-off-by: Lawrence Lee lawlee@microsoft.com
- Loading branch information