浏览代码

modules/ims_registrar_scscf: new parameter notification_list_size_threshold. Once the
notification list exceeds this size a warning is logged.

Richard Good 10 年之前
父节点
当前提交
10ce2e5e1b

+ 3 - 0
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, &notification_list_size_threshold},
 
     {0, 0, 0}
 };

+ 9 - 0
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;

+ 1 - 0
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 */