scheduler: fix multiple SIGSEGV issues on Windows (#1209)
scheduler: fix multiple SIGSEGV issues on Windows (#1209)

* scheduler: fix double free of timer->event

The gist is that we should not call mk_event_del() to remove
timer->event, since it is scheduled to be destroyed later in the
cleanup function flb_sched_timer_cleanup().

I can confirm this fixes the occasional segmentation faults issue
on libevent backend.

Signed-off-by: Fujimoto Seiji <ef879192bb1e41d519c82cf76440dc8e9a530806@clear-code.com>

* scheduler: close communication pipe after invalidating timer

The order of these lines is significant, since closing req->fd wakes
select() on Windows as if the socket has received data.

As such, if we do not invalidate the timer first, it can invoke the
event handler while the destructor is actively releasing the related
resources, which results in SIGSEGV.

Signed-off-by: Fujimoto Seiji <ef879192bb1e41d519c82cf76440dc8e9a530806@clear-code.com>

nokute78/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit