From 197383c682ec72cf1742edd6126906390701bd0d Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Tue, 30 Jan 2024 19:46:25 +0100 Subject: [PATCH] logthrdestdrv: add seqnum and no-seqnum flags Signed-off-by: Balazs Scheidler --- lib/logthrdest/logthrdestdrv.c | 3 +++ lib/logthrdest/logthrdestdrv.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/logthrdest/logthrdestdrv.c b/lib/logthrdest/logthrdestdrv.c index dbf1f4e797b..956154fb3fa 100644 --- a/lib/logthrdest/logthrdestdrv.c +++ b/lib/logthrdest/logthrdestdrv.c @@ -83,6 +83,8 @@ CfgFlagHandler log_threaded_dest_driver_flag_handlers[] = { { "seqnum-all", CFH_SET, offsetof(LogThreadedDestDriver, flags), LTDF_SEQNUM_ALL }, { "no-seqnum-all", CFH_CLEAR, offsetof(LogThreadedDestDriver, flags), LTDF_SEQNUM_ALL }, + { "seqnum", CFH_SET, offsetof(LogThreadedDestDriver, flags), LTDF_SEQNUM }, + { "no-seqnum", CFH_CLEAR, offsetof(LogThreadedDestDriver, flags), LTDF_SEQNUM }, { NULL }, }; @@ -1460,6 +1462,7 @@ log_threaded_dest_driver_init_instance(LogThreadedDestDriver *self, GlobalConfig self->batch_timeout = -1; self->num_workers = 1; self->last_worker = 0; + self->flags = LTDF_SEQNUM; self->retries_on_error_max = MAX_RETRIES_ON_ERROR_DEFAULT; self->retries_max = MAX_RETRIES_BEFORE_SUSPEND_DEFAULT; diff --git a/lib/logthrdest/logthrdestdrv.h b/lib/logthrdest/logthrdestdrv.h index b0bc9fdddb1..1adc9007946 100644 --- a/lib/logthrdest/logthrdestdrv.h +++ b/lib/logthrdest/logthrdestdrv.h @@ -67,6 +67,7 @@ typedef enum enum { LTDF_SEQNUM_ALL = 0x0001, + LTDF_SEQNUM = 0x0002, /* NOTE: everything >= 0x1000 is driver specific */ }; @@ -230,7 +231,8 @@ log_threaded_dest_worker_disconnect(LogThreadedDestWorker *self) static inline LogThreadedResult log_threaded_dest_worker_insert(LogThreadedDestWorker *self, LogMessage *msg) { - if ((self->owner->flags & LTDF_SEQNUM_ALL) || (msg->flags & LF_LOCAL)) + if ((self->owner->flags & LTDF_SEQNUM) && + ((self->owner->flags & LTDF_SEQNUM_ALL) || (msg->flags & LF_LOCAL))) { if (self->owner->num_workers > 1) self->seq_num = step_sequence_number_atomic(&self->owner->shared_seq_num);