diff --git a/include/fluent-bit/flb_coro.h b/include/fluent-bit/flb_coro.h index 987a2164175..c00781135f7 100644 --- a/include/fluent-bit/flb_coro.h +++ b/include/fluent-bit/flb_coro.h @@ -91,6 +91,8 @@ static FLB_INLINE void flb_coro_destroy(struct flb_coro *coro) #define flb_coro_return(th) co_switch(th->caller) void flb_coro_init(); +void flb_coro_thread_init(); + struct flb_coro *flb_coro_get(); void flb_coro_set(struct flb_coro *coro); diff --git a/src/flb_coro.c b/src/flb_coro.c index fa887c53ecc..06bc865e979 100644 --- a/src/flb_coro.c +++ b/src/flb_coro.c @@ -24,9 +24,23 @@ FLB_TLS_DEFINE(struct flb_coro, flb_coro_key); +static pthread_mutex_t coro_mutex_init; + void flb_coro_init() { FLB_TLS_INIT(flb_coro_key); + pthread_mutex_init(&coro_mutex_init, NULL); +} + +void flb_coro_thread_init() +{ + size_t s; + cothread_t th; + + pthread_mutex_lock(&coro_mutex_init); + th = co_create(256, NULL, &s); + co_delete(th); + pthread_mutex_unlock(&coro_mutex_init); } struct flb_coro *flb_coro_get()