Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin: config: Provide windows.maxstdio option for increasing I/O limit on Windows #9707

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_WINDOWS_MAX_STDIO "windows.maxstdio"

/* DNS */
#define FLB_CONF_DNS_MODE "dns.mode"
#define FLB_CONF_DNS_RESOLVER "dns.resolver"
Expand Down
9 changes: 9 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_WINDOWS_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 Expand Up @@ -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
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
Loading