diff --git a/modules/ims_registrar_scscf/reg_mod.c b/modules/ims_registrar_scscf/reg_mod.c index 76e4485b4cb..59829aa35ed 100644 --- a/modules/ims_registrar_scscf/reg_mod.c +++ b/modules/ims_registrar_scscf/reg_mod.c @@ -172,6 +172,7 @@ int subscription_expires_range = 0; int contact_expires_buffer_percentage = 10; /**< percentage we expiry for contact we will substrace from reg response to UE */ int notification_list_size_threshold = 0; /**Threshold for size of notification list after which a warning is logged */ +int max_notification_list_size = 0; int notification_processes = 4; /*Number of processes that processes the notification queue*/ @@ -264,7 +265,6 @@ static param_export_t params[] = { {"store_profile_dereg", INT_PARAM, &store_data_on_dereg}, {"cxdx_forced_peer", PARAM_STR, &cxdx_forced_peer}, {"cxdx_dest_realm", PARAM_STR, &cxdx_dest_realm}, - {"subscription_default_expires", INT_PARAM, &subscription_default_expires}, {"subscription_min_expires", INT_PARAM, &subscription_min_expires}, {"subscription_max_expires", INT_PARAM, &subscription_max_expires}, @@ -273,9 +273,9 @@ static param_export_t params[] = { {"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}, + {"max_notification_list_size", INT_PARAM, &max_notification_list_size}, {"notification_processes", INT_PARAM, ¬ification_processes}, {"send_vs_callid_avp", INT_PARAM, &send_vs_callid_avp}, - {0, 0, 0} }; @@ -288,6 +288,7 @@ stat_export_t mod_stats[] = { {"accepted_regs", 0, &accepted_registrations}, {"rejected_regs", 0, &rejected_registrations}, {"sar_avg_response_time", STAT_IS_FUNC, (stat_var**) get_avg_sar_response_time}, + {"notifies_in_q", STAT_IS_FUNC, (stat_var**) get_notification_list_size}, {"sar_timeouts", 0, (stat_var**) & stat_sar_timeouts}, {0, 0, 0} }; diff --git a/modules/ims_registrar_scscf/registrar_notify.c b/modules/ims_registrar_scscf/registrar_notify.c index 87f0ea33bc8..abd09797c3c 100644 --- a/modules/ims_registrar_scscf/registrar_notify.c +++ b/modules/ims_registrar_scscf/registrar_notify.c @@ -71,14 +71,10 @@ #define EVENT_REFRESHED 4 #define EVENT_EXPIRED 5 -/** - * Initializes the reg notifications list. - */ -reg_notification_list *notification_list = 0; //< List of pending notifications - extern struct tm_binds tmb; extern int notification_list_size_threshold; +extern int max_notification_list_size; extern int subscription_default_expires; extern int subscription_min_expires; @@ -407,7 +403,6 @@ int can_subscribe_to_reg(struct sip_msg *msg, char *_t, char *str2) { while (impucontact) { c = impucontact->contact; - while (j < MAX_CONTACTS_PER_IMPU && (c = r->newcontacts[j])) { if (c->path.len) { LM_DBG("Path: <%.*s>.\n", c->path.len, c->path.s); @@ -524,8 +519,7 @@ int event_reg(udomain_t* _d, impurecord_t* r_passed, int event_type, str *presen } return 0; } - LM_DBG("About to ceate notification"); - + LM_DBG("About to create notification"); create_notifications(_d, r_passed, presentity_uri, watcher_contact, impu_list, num_impus, event_type, explit_dereg_contact, num_explit_dereg_contact); if (impu_list) { pkg_free(impu_list); @@ -1714,7 +1708,6 @@ str generate_reginfo_full(udomain_t* _t, str* impu_list, int num_impus, str *exp LM_DBG("Retrieved IMPU record"); - j = 0; terminate_impu = 1; impucontact = r->linked_contacts.head; @@ -1742,7 +1735,6 @@ str generate_reginfo_full(udomain_t* _t, str* impu_list, int num_impus, str *exp pad.len = strlen(pad.s); STR_APPEND(buf, pad); - j = 0; LM_DBG("Scrolling through contact for this IMPU"); // if (contact && !domain_locked /* we're dealing with the primary impu most likely related to de-reg */) { // LM_DBG("We're dealing with the primary IMPU here AND a contact was passed in - must have been an explicit dereg\n"); @@ -1835,7 +1827,6 @@ str get_reginfo_partial(impurecord_t *r, ucontact_t *c, int event_type) { impurecord = r->linked_contacts.head; while (impurecord) { c_tmp = impurecord->contact; - while (i < MAX_CONTACTS_PER_IMPU && (c_tmp = r->newcontacts[i])) { if ((strncasecmp(c_tmp->c.s, c->c.s, c_tmp->c.len) != 0) && ((c_tmp->expires - act_time) > 0)) { LM_DBG("IMPU <%.*s> has another active contact <%.*s> so will set its state to active\n", r->public_identity.len, r->public_identity.s, c_tmp->c.len, c_tmp->c.s); @@ -2207,6 +2198,12 @@ void add_notification(reg_notification * n) { } else { LM_DBG("Notification exists"); } + + if (max_notification_list_size > 0 && ((notification_list->size+1) > max_notification_list_size )) { + LM_WARN("Dropping notification, list too big [%d]\n", notification_list->size); + return; + } + LM_DBG("Adding to notification list"); lock_get(notification_list->lock); n->next = 0; diff --git a/modules/ims_registrar_scscf/registrar_notify.h b/modules/ims_registrar_scscf/registrar_notify.h index 1241fcc42e1..83424226d76 100644 --- a/modules/ims_registrar_scscf/registrar_notify.h +++ b/modules/ims_registrar_scscf/registrar_notify.h @@ -56,8 +56,6 @@ #define MSG_REG_UNSUBSCRIBE_OK "Subscription to REG dropped" #define MSG_REG_PUBLISH_OK "Publish to REG saved" - - typedef struct _reg_notification { str subscription_state; /**< Subscription-state header value*/ @@ -119,6 +117,8 @@ enum { } IMS_Registrar_events; +reg_notification_list *notification_list; //< List of pending notifications + int can_subscribe_to_reg(struct sip_msg *msg, char *str1, char *str2); int subscribe_to_reg(struct sip_msg *msg, char *str1, char *str2); diff --git a/modules/ims_registrar_scscf/stats.c b/modules/ims_registrar_scscf/stats.c index 01e262d8bce..e0fa51aa2a4 100644 --- a/modules/ims_registrar_scscf/stats.c +++ b/modules/ims_registrar_scscf/stats.c @@ -41,6 +41,7 @@ */ #include "stats.h" +#include "registrar_notify.h" int register_stats() { //SAR @@ -66,3 +67,8 @@ unsigned long get_avg_sar_response_time() { return get_stat_val(sar_replies_response_time)/rpls_received; } + +unsigned long get_notification_list_size() { + return notification_list->size; +} + diff --git a/modules/ims_registrar_scscf/stats.h b/modules/ims_registrar_scscf/stats.h index 52b9a0b461e..81213daa888 100644 --- a/modules/ims_registrar_scscf/stats.h +++ b/modules/ims_registrar_scscf/stats.h @@ -51,6 +51,7 @@ stat_var* sar_replies_response_time; int register_stats(); unsigned long get_avg_sar_response_time(); +unsigned long get_notification_list_size(); #endif /* STATISTICS_H_ */