Skip to content

Commit 99707f2

Browse files
committed
pack: Check whether inside of coroutine or not
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent e14698d commit 99707f2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/flb_pack.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,22 @@ int flb_pack_json(const char *js, size_t len, char **buffer, size_t *size,
671671
#ifdef FLB_HAVE_SIMD
672672
/*
673673
* When SIMD support is compiled in, route the default JSON pack API through
674-
* the extensible frontend so callers inherit the YYJSON backend selection.
674+
* the extensible frontend so callers inherit the YYJSON backend
675+
* selection.
676+
* However, all of the defaulting to use YYSJON is dangerous on
677+
* coroutine.
678+
* So, we only enabled it for normal thread.
679+
* Still, we use legacy backend on using coroutine.
675680
* Explicit backend-specific entry points remain available for forced JSMN
676681
* or YYJSON behavior.
677682
*/
678-
return flb_pack_json_recs_ext(js, len, buffer, size, root_type,
679-
&records, consumed, NULL);
683+
if (flb_coro_get() != NULL) {
684+
return flb_pack_json_legacy(js, len, buffer, size, root_type, consumed);
685+
}
686+
else {
687+
return flb_pack_json_recs_ext(js, len, buffer, size, root_type,
688+
&records, consumed, NULL);
689+
}
680690
#endif
681691

682692
return flb_pack_json_legacy(js, len, buffer, size, root_type, consumed);

0 commit comments

Comments
 (0)