Skip to content

Commit

Permalink
logmsg: add generation counter
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <[email protected]>
  • Loading branch information
bazsi committed Jan 18, 2025
1 parent b4b2a3c commit e1fb711
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/logmsg/logmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ log_msg_set_value_with_type(LogMessage *self, NVHandle handle,
if (value_len < 0)
value_len = strlen(value);

self->generation++;
if (_log_name_value_updates(self))
{
msg_trace("Setting value",
Expand Down Expand Up @@ -651,6 +652,7 @@ log_msg_unset_value(LogMessage *self, NVHandle handle)
{
g_assert(!log_msg_is_write_protected(self));

self->generation++;
if (_log_name_value_updates(self))
{
msg_trace("Unsetting value",
Expand Down Expand Up @@ -712,6 +714,7 @@ log_msg_set_value_indirect_with_type(LogMessage *self, NVHandle handle,
name_len = 0;
name = log_msg_get_value_name(handle, &name_len);

self->generation++;
if (_log_name_value_updates(self))
{
msg_trace("Setting indirect value",
Expand Down Expand Up @@ -951,6 +954,7 @@ log_msg_set_tag_by_id_onoff(LogMessage *self, LogTagId id, gboolean on)

g_assert(!log_msg_is_write_protected(self));

self->generation++;
msg_trace("Setting tag",
evt_tag_str("name", log_tags_get_by_id(id)),
evt_tag_int("value", on),
Expand Down Expand Up @@ -1358,6 +1362,7 @@ log_msg_clear(LogMessage *self)
{
g_assert(!log_msg_is_write_protected(self));

self->generation++;
if(log_msg_chk_flag(self, LF_STATE_OWN_PAYLOAD))
nv_table_unref(self->payload);
self->payload = nv_table_new(LM_V_MAX, 16, 256);
Expand Down
4 changes: 4 additions & 0 deletions lib/logmsg/logmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ struct _LogMessage
gulong *tags;
NVHandle *sdata;

/* this member is incremented for any write operation and it can also
* overflow, so only track it for changes and assume that 2^16 operations
* would suffice between two checks */
guint16 generation;
guint16 pri;
guint8 initial_parse:1,
recursed:1,
Expand Down

0 comments on commit e1fb711

Please sign in to comment.