From b3ecc45d9907cfdf3c3c36cad5e97f5cb9339f89 Mon Sep 17 00:00:00 2001 From: Suvendhu Hansa Date: Wed, 20 Nov 2024 12:54:48 +0530 Subject: [PATCH] Fix notification race condition --- src/notifications.c | 7 +++++-- src/session.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/notifications.c b/src/notifications.c index bd3ebe9..ce77dbb 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -756,6 +756,11 @@ int check_value_change(void) blob_buf_free(&bbuf); } fclose(fp); + + if (notif_ret > 0) { + apply_notify_values(&list_notify_params); + } + cwmp_free_all_dm_parameter_list(&list_notify_params); return notif_ret; } @@ -824,8 +829,6 @@ void periodic_check_notifiy(struct uloop_timeout *timeout __attribute__((unused cr_url_retry = 3; is_notify = check_value_change(); - if (is_notify > 0) - cwmp_update_enabled_notify_file(); if (is_notify & NOTIF_ACTIVE) { send_active_value_change(); int last_session_interval = time(NULL) - cwmp_ctx.session->session_status.last_end_time; diff --git a/src/session.c b/src/session.c index 4922546..f2c65b9 100644 --- a/src/session.c +++ b/src/session.c @@ -377,15 +377,21 @@ void start_cwmp_session(void) * Value changes */ if (!cwmp_ctx.session->session_status.is_heartbeat) { - int is_notify = 0; if (file_exists(DM_ENABLED_NOTIFY)) { + int is_notify = 0; + if (!event_exist_in_list(EVENT_IDX_4VALUE_CHANGE)) is_notify = check_value_change(); + + if (is_notify > 0) + cwmp_ctx.custom_notify_active = false; } - if (is_notify > 0 || !file_exists(DM_ENABLED_NOTIFY) || cwmp_ctx.custom_notify_active) { + + if (!file_exists(DM_ENABLED_NOTIFY) || cwmp_ctx.custom_notify_active) { cwmp_ctx.custom_notify_active = false; cwmp_update_enabled_notify_file(); } + cwmp_prepare_value_change(); clean_list_value_change(); }