diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2021-11-01 08:58:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 08:58:38 +0200 |
commit | 08f8695a5b344f7ace09aa97c1a2ec3fb08a6e9d (patch) | |
tree | ef21489cb218af9142dd7f1a4a0eb626e981f8d7 /database | |
parent | 69e576bec1b3577175630a5b22e4c928b35b0dc2 (diff) |
Move initial snapshot_proto generation inside the loop (#11719)
Diffstat (limited to 'database')
-rw-r--r-- | database/sqlite/sqlite_aclk_alert.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/database/sqlite/sqlite_aclk_alert.c b/database/sqlite/sqlite_aclk_alert.c index a8dcc1a8c3..0e86b0461b 100644 --- a/database/sqlite/sqlite_aclk_alert.c +++ b/database/sqlite/sqlite_aclk_alert.c @@ -778,8 +778,7 @@ void aclk_push_alert_snapshot_event(struct aclk_database_worker_config *wc, stru alarm_snap.chunks = chunks; alarm_snap.chunk = chunk; - alarm_snapshot_proto_ptr_t snapshot_proto; - snapshot_proto = generate_alarm_snapshot_proto(&alarm_snap); + alarm_snapshot_proto_ptr_t snapshot_proto = NULL; for (; ae; ae = ae->next) { if (likely(ae->updated_by_id)) @@ -791,15 +790,18 @@ void aclk_push_alert_snapshot_event(struct aclk_database_worker_config *wc, stru if (have_recent_alarm(host, ae->alarm_id, ae->unique_id)) continue; + cnt++; + struct alarm_log_entry alarm_log; alarm_log.node_id = wc->node_id; alarm_log.claim_id = claim_id; + if (!snapshot_proto) + snapshot_proto = generate_alarm_snapshot_proto(&alarm_snap); + health_alarm_entry2proto_nolock(&alarm_log, ae, host); add_alarm_log_entry2snapshot(snapshot_proto, &alarm_log); - cnt++; - if (cnt == ALARM_EVENTS_PER_CHUNK) { aclk_send_alarm_snapshot(snapshot_proto); |