Skip to content

Commit

Permalink
modules/ims_registrar_scscf: add param max_notification list size and…
Browse files Browse the repository at this point in the history
… stat of current size
  • Loading branch information
jaybeepee committed Oct 20, 2016
1 parent fa347d4 commit 843646b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
5 changes: 3 additions & 2 deletions modules/ims_registrar_scscf/reg_mod.c
Expand Up @@ -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*/

Expand Down Expand Up @@ -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},
Expand All @@ -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, &notification_list_size_threshold},
{"max_notification_list_size", INT_PARAM, &max_notification_list_size},
{"notification_processes", INT_PARAM, &notification_processes},
{"send_vs_callid_avp", INT_PARAM, &send_vs_callid_avp},

{0, 0, 0}
};

Expand All @@ -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}
};
Expand Down
19 changes: 8 additions & 11 deletions modules/ims_registrar_scscf/registrar_notify.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions modules/ims_registrar_scscf/registrar_notify.h
Expand Up @@ -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*/
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions modules/ims_registrar_scscf/stats.c
Expand Up @@ -41,6 +41,7 @@
*/

#include "stats.h"
#include "registrar_notify.h"

int register_stats() {
//SAR
Expand All @@ -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;
}

1 change: 1 addition & 0 deletions modules/ims_registrar_scscf/stats.h
Expand Up @@ -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_ */

0 comments on commit 843646b

Please sign in to comment.