app: fix crash on logrotate and immediate exit
`say_logrotate` does not rotate logs synchronously. It posts tasks to coio which executes them in it's pool thread. On application exit we destroy logs calling `log_destroy`. This function waits for rotate task to finish because if it will free resources immediately then unfinished rotate task can have use-after-free issues. Waiting crashes because at this moment event loop is not running which is required for `fiber_cond_wait` to work. Note that if there is no crash then we will hang forever waiting in `log_destroy` because event loop is not running and `log_rotate_async_cb` will never be executed. Let's use mutexes and conditions instead. It solves both problems with crash and hang. Thanks Vladimir Davydov for idea. Fixes #4450 NO_DOC=bugfix
Showing
- changelogs/unreleased/gh-4450-fix-crash-on-logrotate-and-exit.md 3 additions, 0 deletions...ogs/unreleased/gh-4450-fix-crash-on-logrotate-and-exit.md
- src/lib/core/say.c 17 additions, 19 deletionssrc/lib/core/say.c
- src/lib/core/say.h 7 additions, 8 deletionssrc/lib/core/say.h
- test/unit/say.c 7 additions, 0 deletionstest/unit/say.c
Loading