Skip to content

Commit a5bc459

Browse files
cosmo0920edsiper
authored andcommitted
bin: config: Provide maxstdio option for increasing I/O limit on Windows
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent ea9853f commit a5bc459

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

include/fluent-bit/flb_config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ struct flb_config {
287287
size_t route_mask_size;
288288
size_t route_mask_slots;
289289
uint64_t *route_empty_mask;
290+
#ifdef FLB_SYSTEM_WINDOWS
291+
/* maxstdio (Windows) */
292+
int maxstdio;
293+
#endif
290294

291295
/* Co-routines */
292296
unsigned int coro_stack_size;
@@ -373,6 +377,9 @@ enum conf_type {
373377
#define FLB_CONF_STR_HOT_RELOAD "Hot_Reload"
374378
#define FLB_CONF_STR_HOT_RELOAD_ENSURE_THREAD_SAFETY "Hot_Reload.Ensure_Thread_Safety"
375379

380+
/* Set up maxstdio (Windows) */
381+
#define FLB_CONF_STR_MAX_STDIO "Max_Stdio"
382+
376383
/* DNS */
377384
#define FLB_CONF_DNS_MODE "dns.mode"
378385
#define FLB_CONF_DNS_RESOLVER "dns.resolver"

src/flb_config.c

Lines changed: 9 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)},
@@ -291,6 +296,10 @@ struct flb_config *flb_config_init()
291296
config->shutdown_by_hot_reloading = FLB_FALSE;
292297
config->hot_reloading = FLB_FALSE;
293298

299+
#ifdef FLB_SYSTEM_WINDOWS
300+
config->maxstdio = 512;
301+
#endif
302+
294303
#ifdef FLB_HAVE_SQLDB
295304
mk_list_init(&config->sqldb_list);
296305
#endif

src/fluent-bit.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,9 @@ int flb_main(int argc, char **argv)
10671067
{ "http_port", required_argument, NULL, 'P' },
10681068
#endif
10691069
{ "enable-hot-reload", no_argument, NULL, 'Y' },
1070+
#ifdef FLB_SYSTEM_WINDOWS
1071+
{ "maxstdio", required_argument, NULL, 'M' },
1072+
#endif
10701073
#ifdef FLB_HAVE_CHUNK_TRACE
10711074
{ "enable-chunk-trace", no_argument, NULL, 'Z' },
10721075
{ "trace", required_argument, NULL, FLB_LONG_TRACE },
@@ -1104,7 +1107,7 @@ int flb_main(int argc, char **argv)
11041107

11051108
/* Parse the command line options */
11061109
while ((opt = getopt_long(argc, argv,
1107-
"b:c:dDf:C:i:m:o:R:r:F:p:e:"
1110+
"b:c:dDf:C:i:m:M:o:R:r:F:p:e:"
11081111
"t:T:l:vw:qVhJL:HP:s:SWYZ",
11091112
long_opts, NULL)) != -1) {
11101113

@@ -1159,6 +1162,12 @@ int flb_main(int argc, char **argv)
11591162
flb_cf_section_property_add(cf_opts, s->properties, "match", 0, optarg, 0);
11601163
}
11611164
break;
1165+
#ifdef FLB_SYSTEM_WINDOWS
1166+
case 'M':
1167+
flb_cf_section_property_add(cf_opts, service->properties,
1168+
"max_stdio", 0, optarg, 0);
1169+
break;
1170+
#endif
11621171
case 'o':
11631172
s = flb_cf_section_create(cf_opts, "output", 0);
11641173
if (!s) {
@@ -1391,6 +1400,18 @@ int flb_main(int argc, char **argv)
13911400
#endif
13921401

13931402
#ifdef FLB_SYSTEM_WINDOWS
1403+
/* Validate specified maxstdio */
1404+
if (config->maxstdio >= 512 && config->maxstdio <= 2048) {
1405+
_setmaxstdio(config->maxstdio);
1406+
}
1407+
else {
1408+
fprintf(stderr,
1409+
"maxstdio is invalid. From 512 to 2048 is vaild but got %d\n",
1410+
config->maxstdio);
1411+
flb_free(cfg_file);
1412+
flb_cf_destroy(cf_opts);
1413+
exit(EXIT_FAILURE);
1414+
}
13941415
win32_started();
13951416
#endif
13961417

0 commit comments

Comments
 (0)