Skip to content

Commit

Permalink
bin: config: Provide maxstdio option for increasing I/O limit on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
  • Loading branch information
cosmo0920 committed Dec 11, 2024
1 parent bfa594c commit ccd1d52
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/fluent-bit/flb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/flb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
23 changes: 22 additions & 1 deletion src/fluent-bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ccd1d52

Please sign in to comment.