46
46
#include <winnt.h>
47
47
#endif
48
48
49
+ static inline void sync_fetch_and_add (size_t * dest , size_t value ) {
50
+ #ifdef FLB_SYSTEM_WINDOWS
51
+ InterlockedAdd (dest , value );
52
+ #else
53
+ __sync_fetch_and_add (dest , value );
54
+ #endif
55
+ }
56
+
49
57
static int cb_doris_init (struct flb_output_instance * ins ,
50
58
struct flb_config * config , void * data )
51
59
{
@@ -317,11 +325,7 @@ static void cb_doris_flush(struct flb_event_chunk *event_chunk,
317
325
318
326
if (ret != FLB_OK ) {
319
327
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
323
- __sync_fetch_and_add (& ctx -> reporter -> failed_rows , event_chunk -> total_events );
324
- #endif
328
+ sync_fetch_and_add (& ctx -> reporter -> failed_rows , event_chunk -> total_events );
325
329
}
326
330
FLB_OUTPUT_RETURN (ret );
327
331
}
@@ -337,19 +341,10 @@ static void cb_doris_flush(struct flb_event_chunk *event_chunk,
337
341
flb_sds_destroy (out_body );
338
342
339
343
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
344
- __sync_fetch_and_add (& ctx -> reporter -> total_bytes , out_size );
345
- __sync_fetch_and_add (& ctx -> reporter -> total_rows , event_chunk -> total_events );
346
- #endif
344
+ sync_fetch_and_add (& ctx -> reporter -> total_bytes , out_size );
345
+ sync_fetch_and_add (& ctx -> reporter -> total_rows , event_chunk -> total_events );
347
346
} 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
351
- __sync_fetch_and_add (& ctx -> reporter -> failed_rows , event_chunk -> total_events );
352
- #endif
347
+ sync_fetch_and_add (& ctx -> reporter -> failed_rows , event_chunk -> total_events );
353
348
}
354
349
FLB_OUTPUT_RETURN (ret );
355
350
}
0 commit comments