hrydgard / minitrace

Simple C/C++ library for producing JSON traces suitable for Chrome's built-in trace viewer (about:tracing).
MIT License
373 stars 64 forks source link

Set is_flushing to FALSE in mtr_init_from_stream #43

Closed azuraw10 closed 9 months ago

azuraw10 commented 9 months ago

Hi, this PR sets is_flushing to FALSE in mtr_init_from_stream. The problem was that it was not possible to call init+shutdown multiple times - is_flushing is set to TRUE in shutdown, so another mtr_init call and trying to add traces had no effect (traces were not added to the file due to an early return in mtr_flush_with_state function). It has been done like this probably so that it is not possible to perform flush after mtr_shutdown. However, such approach makes it impossible to properly reinitialize the tracer. Settings is_flushing to FALSE in mtr_init_from_stream, adds the ability to call init+shutdown multiple times. Thanks to this, it is possible to create many traces files in the same run of the application.