Skip to content

Commit eb2d7e7

Browse files
committed
fix: windows atomic
Signed-off-by: composer <[email protected]>
1 parent 28b1363 commit eb2d7e7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

plugins/out_doris/doris.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242

4343
#include <fluent-bit/flb_callback.h>
4444

45+
#ifdef FLB_SYSTEM_WINDOWS
46+
#include <winnt.h>
47+
#endif
48+
4549
static int cb_doris_init(struct flb_output_instance *ins,
4650
struct flb_config *config, void *data)
4751
{
@@ -313,7 +317,11 @@ static void cb_doris_flush(struct flb_event_chunk *event_chunk,
313317

314318
if (ret != FLB_OK) {
315319
if (ret == FLB_ERROR && ctx->log_progress_interval > 0) {
320+
#ifdef FLB_SYSTEM_WINDOWS
321+
InterlockedAdd(&ctx->reporter->failed_rows, event_chunk->total_events);
322+
#else
316323
__sync_fetch_and_add(&ctx->reporter->failed_rows, event_chunk->total_events);
324+
#endif
317325
}
318326
FLB_OUTPUT_RETURN(ret);
319327
}
@@ -329,10 +337,19 @@ static void cb_doris_flush(struct flb_event_chunk *event_chunk,
329337
flb_sds_destroy(out_body);
330338

331339
if (ret == FLB_OK && ctx->log_progress_interval > 0) {
340+
#ifdef FLB_SYSTEM_WINDOWS
341+
InterlockedAdd(&ctx->reporter->total_bytes, out_size);
342+
InterlockedAdd(&ctx->reporter->total_rows, event_chunk->total_events);
343+
#else
332344
__sync_fetch_and_add(&ctx->reporter->total_bytes, out_size);
333345
__sync_fetch_and_add(&ctx->reporter->total_rows, event_chunk->total_events);
346+
#endif
334347
} else if (ret == FLB_ERROR && ctx->log_progress_interval > 0) {
348+
#ifdef FLB_SYSTEM_WINDOWS
349+
InterlockedAdd(&ctx->reporter->failed_rows, event_chunk->total_events);
350+
#else
335351
__sync_fetch_and_add(&ctx->reporter->failed_rows, event_chunk->total_events);
352+
#endif
336353
}
337354
FLB_OUTPUT_RETURN(ret);
338355
}

0 commit comments

Comments
 (0)