diff --git a/include/fluent-bit/flb_config.h b/include/fluent-bit/flb_config.h index 1cfc6301ff8..bfed0c80c56 100644 --- a/include/fluent-bit/flb_config.h +++ b/include/fluent-bit/flb_config.h @@ -269,6 +269,11 @@ struct flb_config { int shutdown_by_hot_reloading; int hot_reloading; +#ifdef FLB_SYSTEM_WINDOWS + /* maxstdio (Windows) */ + int maxstdio; +#endif + /* Co-routines */ unsigned int coro_stack_size; @@ -351,6 +356,9 @@ enum conf_type { #define FLB_CONF_STR_HOT_RELOAD "Hot_Reload" #define FLB_CONF_STR_HOT_RELOAD_ENSURE_THREAD_SAFETY "Hot_Reload.Ensure_Thread_Safety" +/* Set up maxstdio (Windows) */ +#define FLB_CONF_STR_MAX_STDIO "Max_Stdio" + /* DNS */ #define FLB_CONF_DNS_MODE "dns.mode" #define FLB_CONF_DNS_RESOLVER "dns.resolver" diff --git a/src/flb_config.c b/src/flb_config.c index 32dc34b7e83..3b2ce3f1651 100644 --- a/src/flb_config.c +++ b/src/flb_config.c @@ -183,6 +183,11 @@ struct flb_service_config service_configs[] = { offsetof(struct flb_config, enable_chunk_trace)}, #endif +#ifdef FLB_SYSTEM_WINDOWS + {FLB_CONF_STR_MAX_STDIO, + FLB_CONF_TYPE_INT, + offsetof(struct flb_config, maxstdio)}, +#endif {FLB_CONF_STR_HOT_RELOAD, FLB_CONF_TYPE_BOOL, offsetof(struct flb_config, enable_hot_reload)}, @@ -288,6 +293,10 @@ struct flb_config *flb_config_init() config->shutdown_by_hot_reloading = FLB_FALSE; config->hot_reloading = FLB_FALSE; +#ifdef FLB_SYSTEM_WINDOWS + config->maxstdio = 512; +#endif + #ifdef FLB_HAVE_SQLDB mk_list_init(&config->sqldb_list); #endif diff --git a/src/fluent-bit.c b/src/fluent-bit.c index 6444b333f2d..116b5acf79a 100644 --- a/src/fluent-bit.c +++ b/src/fluent-bit.c @@ -1036,6 +1036,9 @@ int flb_main(int argc, char **argv) { "http_port", required_argument, NULL, 'P' }, #endif { "enable-hot-reload", no_argument, NULL, 'Y' }, +#ifdef FLB_SYSTEM_WINDOWS + { "maxstdio", required_argument, NULL, 'M' }, +#endif #ifdef FLB_HAVE_CHUNK_TRACE { "enable-chunk-trace", no_argument, NULL, 'Z' }, { "trace", required_argument, NULL, FLB_LONG_TRACE }, @@ -1073,7 +1076,7 @@ int flb_main(int argc, char **argv) /* Parse the command line options */ while ((opt = getopt_long(argc, argv, - "b:c:dDf:C:i:m:o:R:F:p:e:" + "b:c:dDf:C:i:m:M:o:R:F:p:e:" "t:T:l:vw:qVhJL:HP:s:SWYZ", long_opts, NULL)) != -1) { @@ -1128,6 +1131,12 @@ int flb_main(int argc, char **argv) flb_cf_section_property_add(cf_opts, s->properties, "match", 0, optarg, 0); } break; +#ifdef FLB_SYSTEM_WINDOWS + case 'M': + flb_cf_section_property_add(cf_opts, service->properties, + "max_stdio", 0, optarg, 0); + break; +#endif case 'o': s = flb_cf_section_create(cf_opts, "output", 0); if (!s) { @@ -1350,6 +1359,18 @@ int flb_main(int argc, char **argv) #endif #ifdef FLB_SYSTEM_WINDOWS + /* Validate specified maxstdio */ + if (config->maxstdio >= 512 && config->maxstdio <= 2048) { + _setmaxstdio(config->maxstdio); + } + else { + fprintf(stderr, + "maxstdio is invalid. From 512 to 2048 is vaild but got %d\n", + config->maxstdio); + flb_free(cfg_file); + flb_cf_destroy(cf_opts); + exit(EXIT_FAILURE); + } win32_started(); #endif