Skip to content

Commit c5a552f

Browse files
committed
bin: config: Provide maxstdio option for increasing I/O limit on Windows
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent bfa594c commit c5a552f

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

include/fluent-bit/flb_config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ struct flb_config {
269269
int shutdown_by_hot_reloading;
270270
int hot_reloading;
271271

272+
#ifdef FLB_SYSTEM_WINDOWS
273+
/* maxstdio (Windows) */
274+
int maxstdio;
275+
#endif
276+
272277
/* Co-routines */
273278
unsigned int coro_stack_size;
274279

@@ -351,6 +356,9 @@ enum conf_type {
351356
#define FLB_CONF_STR_HOT_RELOAD "Hot_Reload"
352357
#define FLB_CONF_STR_HOT_RELOAD_ENSURE_THREAD_SAFETY "Hot_Reload.Ensure_Thread_Safety"
353358

359+
/* Set up maxstdio (Windows) */
360+
#define FLB_CONF_STR_MAX_STDIO "Max_Stdio"
361+
354362
/* DNS */
355363
#define FLB_CONF_DNS_MODE "dns.mode"
356364
#define FLB_CONF_DNS_RESOLVER "dns.resolver"

src/flb_config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ struct flb_service_config service_configs[] = {
183183
offsetof(struct flb_config, enable_chunk_trace)},
184184
#endif
185185

186+
#ifdef FLB_SYSTEM_WINDOWS
187+
{FLB_CONF_STR_MAX_STDIO,
188+
FLB_CONF_TYPE_INT,
189+
offsetof(struct flb_config, maxstdio)},
190+
#endif
186191
{FLB_CONF_STR_HOT_RELOAD,
187192
FLB_CONF_TYPE_BOOL,
188193
offsetof(struct flb_config, enable_hot_reload)},

src/fluent-bit.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,9 @@ int flb_main(int argc, char **argv)
10361036
{ "http_port", required_argument, NULL, 'P' },
10371037
#endif
10381038
{ "enable-hot-reload", no_argument, NULL, 'Y' },
1039+
#ifdef FLB_SYSTEM_WINDOWS
1040+
{ "maxstdio", required_argument, NULL, 'M' },
1041+
#endif
10391042
#ifdef FLB_HAVE_CHUNK_TRACE
10401043
{ "enable-chunk-trace", no_argument, NULL, 'Z' },
10411044
{ "trace", required_argument, NULL, FLB_LONG_TRACE },
@@ -1073,7 +1076,7 @@ int flb_main(int argc, char **argv)
10731076

10741077
/* Parse the command line options */
10751078
while ((opt = getopt_long(argc, argv,
1076-
"b:c:dDf:C:i:m:o:R:F:p:e:"
1079+
"b:c:dDf:C:i:m:M:o:R:F:p:e:"
10771080
"t:T:l:vw:qVhJL:HP:s:SWYZ",
10781081
long_opts, NULL)) != -1) {
10791082

@@ -1128,6 +1131,12 @@ int flb_main(int argc, char **argv)
11281131
flb_cf_section_property_add(cf_opts, s->properties, "match", 0, optarg, 0);
11291132
}
11301133
break;
1134+
#ifdef FLB_SYSTEM_WINDOWS
1135+
case 'M':
1136+
flb_cf_section_property_add(cf_opts, service->properties,
1137+
"max_stdio", 0, optarg, 0);
1138+
break;
1139+
#endif
11311140
case 'o':
11321141
s = flb_cf_section_create(cf_opts, "output", 0);
11331142
if (!s) {
@@ -1350,6 +1359,21 @@ int flb_main(int argc, char **argv)
13501359
#endif
13511360

13521361
#ifdef FLB_SYSTEM_WINDOWS
1362+
/* Validate specified maxstdio */
1363+
if (config->maxstdio >= 512 && config->maxstdio <= 2048) {
1364+
_setmaxstdio(config->maxstdio);
1365+
}
1366+
else if (config->maxstdio == 0) {
1367+
/* nop */
1368+
}
1369+
else {
1370+
fprintf(stderr,
1371+
"maxstdio is invalid. From 512 to 2048 is vaild but got %d\n",
1372+
config->maxstdio);
1373+
flb_free(cfg_file);
1374+
flb_cf_destroy(cf_opts);
1375+
exit(EXIT_FAILURE);
1376+
}
13531377
win32_started();
13541378
#endif
13551379

0 commit comments

Comments
 (0)