From 99707f287189034fc7dc78fb6f0326342e563660 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 23 Mar 2026 19:24:35 +0100 Subject: [PATCH] pack: Check whether inside of coroutine or not Signed-off-by: Hiroshi Hatake --- src/flb_pack.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/flb_pack.c b/src/flb_pack.c index 6c40e3b82f2..5aa77760bfd 100644 --- a/src/flb_pack.c +++ b/src/flb_pack.c @@ -671,12 +671,22 @@ int flb_pack_json(const char *js, size_t len, char **buffer, size_t *size, #ifdef FLB_HAVE_SIMD /* * When SIMD support is compiled in, route the default JSON pack API through - * the extensible frontend so callers inherit the YYJSON backend selection. + * the extensible frontend so callers inherit the YYJSON backend + * selection. + * However, all of the defaulting to use YYSJON is dangerous on + * coroutine. + * So, we only enabled it for normal thread. + * Still, we use legacy backend on using coroutine. * Explicit backend-specific entry points remain available for forced JSMN * or YYJSON behavior. */ - return flb_pack_json_recs_ext(js, len, buffer, size, root_type, - &records, consumed, NULL); + if (flb_coro_get() != NULL) { + return flb_pack_json_legacy(js, len, buffer, size, root_type, consumed); + } + else { + return flb_pack_json_recs_ext(js, len, buffer, size, root_type, + &records, consumed, NULL); + } #endif return flb_pack_json_legacy(js, len, buffer, size, root_type, consumed);