From 10ce2e5e1b6a2e158ce031487426230afb370682 Mon Sep 17 00:00:00 2001 From: Richard Good Date: Tue, 20 Jan 2015 10:59:25 +0200 Subject: [PATCH] modules/ims_registrar_scscf: new parameter notification_list_size_threshold. Once the notification list exceeds this size a warning is logged. --- modules/ims_registrar_scscf/reg_mod.c | 3 +++ modules/ims_registrar_scscf/registrar_notify.c | 9 +++++++++ modules/ims_registrar_scscf/registrar_notify.h | 1 + 3 files changed, 13 insertions(+) diff --git a/modules/ims_registrar_scscf/reg_mod.c b/modules/ims_registrar_scscf/reg_mod.c index 87ec202670a..f1ced688129 100644 --- a/modules/ims_registrar_scscf/reg_mod.c +++ b/modules/ims_registrar_scscf/reg_mod.c @@ -156,6 +156,8 @@ int subscription_min_expires = 10; /**< minimum subscription expiration time * int subscription_max_expires = 1000000; /**< maximum subscription expiration time */ int subscription_expires_range = 0; +int notification_list_size_threshold = 0; /**Threshold for size of notification list after which a warning is logged */ + extern reg_notification_list *notification_list; /**< list of notifications for reg to be sent */ @@ -251,6 +253,7 @@ static param_export_t params[] = { {"ue_unsubscribe_on_dereg", INT_PARAM, &ue_unsubscribe_on_dereg}, {"subscription_expires_range", INT_PARAM, &subscription_expires_range}, {"user_data_always", INT_PARAM, &user_data_always}, + {"notification_list_size_threshold", INT_PARAM, ¬ification_list_size_threshold}, {0, 0, 0} }; diff --git a/modules/ims_registrar_scscf/registrar_notify.c b/modules/ims_registrar_scscf/registrar_notify.c index 38762c0aa9e..2ab9ec02205 100644 --- a/modules/ims_registrar_scscf/registrar_notify.c +++ b/modules/ims_registrar_scscf/registrar_notify.c @@ -77,6 +77,8 @@ reg_notification_list *notification_list = 0; //< List of pending notifications extern struct tm_binds tmb; +extern int notification_list_size_threshold; + extern int subscription_default_expires; extern int subscription_min_expires; extern int subscription_max_expires; @@ -121,6 +123,7 @@ int notify_init() { return 0; } notification_list->lock = lock_init(notification_list->lock); + notification_list->size = 0; sem_new(notification_list->empty, 0); //pre-locked - as we assume list is empty at start return 1; } @@ -1995,6 +1998,11 @@ void add_notification(reg_notification * n) { if (notification_list->tail) notification_list->tail->next = n; notification_list->tail = n; if (!notification_list->head) notification_list->head = n; + notification_list->size++; + if(notification_list_size_threshold > 0 && notification_list->size > notification_list_size_threshold) { + LM_WARN("notification_list is size [%d] and has exceed notification_list_size_threshold of [%d]", notification_list->size, notification_list_size_threshold); + } + sem_release(notification_list->empty); lock_release(notification_list->lock); } @@ -2019,6 +2027,7 @@ reg_notification* get_notification() { notification_list->tail = 0; } n->next = 0; //make sure whoever gets this cant access our list + notification_list->size--; lock_release(notification_list->lock); return n; diff --git a/modules/ims_registrar_scscf/registrar_notify.h b/modules/ims_registrar_scscf/registrar_notify.h index 3dd8c173e9f..1a4441234e7 100644 --- a/modules/ims_registrar_scscf/registrar_notify.h +++ b/modules/ims_registrar_scscf/registrar_notify.h @@ -88,6 +88,7 @@ typedef struct { reg_notification *head; /**< first notification in the list */ reg_notification *tail; /**< last notification in the list */ gen_sem_t *empty; + int size; } reg_notification_list; /** Events for subscriptions */