Module: sip-router
Branch: master
Commit: 6eb29ad5164400e1e66ac7eb106220b012b46115
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6eb29ad…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Thu Oct 30 15:47:25 2014 +0200
modules/ims_registrar_scscf: new mod_param subscription_expires_range
If set this parameter randomises the subscription expiry
Works exactly the same as usrloc expires_range param
---
.../doc/ims_registrar_scscf_admin.xml | 91 ++++++++++++++++++-
modules/ims_registrar_scscf/reg_mod.c | 2 +
modules/ims_registrar_scscf/registrar_notify.c | 18 ++++
modules/ims_registrar_scscf/save.c | 19 ++++
4 files changed, 125 insertions(+), 5 deletions(-)
diff --git a/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml b/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml
index 0964b5e..e80d6d0 100644
--- a/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml
+++ b/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml
@@ -67,7 +67,7 @@
contact parameters, this value will be used for newly created S-CSCF
usrloc records. The parameter contains number of second to expire (for
example use 3600 for one hour). If it is set to a lower value than the
- “min_expires” parameter then it will be ignored. This
+ min_expires parameter then it will be ignored. This
parameter can be modified via ser config framework. A random value in a
specific interval can be selected by using the default_expires_range
parameter</para>
@@ -87,10 +87,10 @@
<title>default_expires_range (int)</title>
<para>This parameter specifies that the expiry used for newly created
- S-CSCF usrloc records are not fixed(when “default_expires”
- applies), but a random value in the interval
- “[default_expires-default_expires_range%,
- default_expires+default_expires_range%]”. The value is between 0
+ S-CSCF usrloc records are not fixed(when default_expires
+ applies), but a random value in the intervalrdq
+ [default_expires-default_expires_range%,
+ default_expires+default_expires_range%]. The value is between 0
and 100 and represent the maximim percentage from default_expires that
will be substracted or added when computing the value. Default in 0,
meaning default_expires is left unmodified. This parameter can be
@@ -144,6 +144,87 @@
...</programlisting>
</example>
</section>
+
+ <section>
+ <title>subscription_default_expires (int)</title>
+
+ <para>If the processed message contains neither Expires HFs nor expires
+ contact parameters, this value will be used for newly created subscriptions.
+ The parameter contains number of second to expire (for example use 3600 for one hour).
+ If it is set to a lower value than the subscription_min_expires parameter
+ then it will be ignored. A random value in a specific interval can be selected
+ by using the subscription_expires_range parameter</para>
+
+ <para><emphasis> Default value is 3600. </emphasis></para>
+
+ <example>
+ <title>Set <varname>subscription_default_expires</varname> parameter</title>
+
+ <programlisting format="linespecific">...
+ modparam("ims_registrar_scscf", "subscription_default_expires", 3600)
+...</programlisting>
+ </example>
+ </section>
+
+ <section>
+ <title>subscription_expires_range (int)</title>
+
+ <para>This parameter specifies that the expiry used for newly created
+ subscriptions are not fixed(when subscription_default_expires
+ applies), but a random value in the interval
+ [subscription_default_expires-subscription_expires_range%,
+ subscription_default_expires+subscription_expires_range%].
+ The value is between 0 and 100 and represent the maximim percentage
+ from subscription_default_expires that will be substracted or added when
+ computing the value. Default in 0, meaning subscription_default_expires is
+ left unmodified.</para>
+
+ <para><emphasis> Default value is 0. </emphasis></para>
+
+ <example>
+ <title>Set <varname>subscription_expires_range </varname>parameter</title>
+
+ <programlisting format="linespecific">...
+ modparam("ims_registrar_scscf", "subscription_expires_range", 30) # +- 30% from subscription_expires_range
+...</programlisting>
+ </example>
+ </section>
+
+ <section>
+ <title>subscription_min_expires (int)</title>
+
+ <para>The minimum expires value of a subscription, values lower than this
+ minimum will be automatically set to the minimum. Value 0 disables the
+ checking.</para>
+
+ <para><emphasis> Default value is 10. </emphasis></para>
+
+ <example>
+ <title>Set <varname>subscription_min_expires</varname>parameter</title>
+
+ <programlisting format="linespecific">...
+ modparam("subscription_min_expires", "min_expires", 1800)
+...</programlisting>
+ </example>
+ </section>
+
+ <section>
+ <title>subscription_max_expires (int)</title>
+
+ <para>The maximum expires value of a subscription, values higher than this
+ maximum will be automatically set to the maximum. Value 0 disables the
+ checking.</para>
+
+ <para><emphasis> Default value is 1000000. </emphasis></para>
+
+ <example>
+ <title>Set <varname>subscription_max_expires</varname>parameter</title>
+
+ <programlisting format="linespecific">...
+ modparam("ims_registrar_scscf", "subscription_max_expires", 3600)
+...</programlisting>
+ </example>
+ </section>
<section>
<title>user_data_dtd (string)</title>
diff --git a/modules/ims_registrar_scscf/reg_mod.c b/modules/ims_registrar_scscf/reg_mod.c
index 3a39ec1..d412e37 100644
--- a/modules/ims_registrar_scscf/reg_mod.c
+++ b/modules/ims_registrar_scscf/reg_mod.c
@@ -153,6 +153,7 @@ str sock_hdr_name = {0, 0};
int subscription_default_expires = 3600; /**< the default value for expires if none found*/
int subscription_min_expires = 10; /**< minimum subscription expiration time */
int subscription_max_expires = 1000000; /**< maximum subscription expiration time */
+int subscription_expires_range = 0;
extern reg_notification_list *notification_list; /**< list of notifications for reg to be sent */
@@ -246,6 +247,7 @@ static param_export_t params[] = {
{"subscription_min_expires", INT_PARAM, &subscription_min_expires},
{"subscription_max_expires", INT_PARAM, &subscription_max_expires},
{"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},
{0, 0, 0}
diff --git a/modules/ims_registrar_scscf/registrar_notify.c b/modules/ims_registrar_scscf/registrar_notify.c
index 93c0e2d..17a1266 100644
--- a/modules/ims_registrar_scscf/registrar_notify.c
+++ b/modules/ims_registrar_scscf/registrar_notify.c
@@ -91,6 +91,22 @@ static str ctype_hdr1 = {"Content-Type: ", 14};
static str ctype_hdr2 = {"\r\n", 2};
extern int ue_unsubscribe_on_dereg;
+extern int subscription_expires_range;
+
+/* \brief
+ * Return randomized expires between expires-range% and expires.
+ * RFC allows only value less or equal to the one provided by UAC.
+ */
+
+static inline int randomize_expires( int expires, int range )
+{
+ /* if no range is given just return expires */
+ if(range == 0) return expires;
+
+ int range_min = expires - (float)range/100 * expires;
+
+ return range_min + (float)(rand()%100)/100 * ( expires - range_min );
+}
int notify_init() {
notification_list = shm_malloc(sizeof (reg_notification_list));
@@ -1055,6 +1071,8 @@ int subscribe_to_reg(struct sip_msg *msg, char *_t, char *str2) {
if (expires < subscription_min_expires) expires = subscription_min_expires;
if (expires > subscription_max_expires) expires = subscription_max_expires;
+
+ expires = randomize_expires(expires, subscription_expires_range);
get_act_time();
expires_time = expires + act_time;
diff --git a/modules/ims_registrar_scscf/save.c b/modules/ims_registrar_scscf/save.c
index 3066019..5189f7f 100644
--- a/modules/ims_registrar_scscf/save.c
+++ b/modules/ims_registrar_scscf/save.c
@@ -86,6 +86,22 @@ extern int store_data_on_dereg; /**< should we store SAR user data on de-registr
extern int ue_unsubscribe_on_dereg;
extern int user_data_always;
+
+/* \brief
+ * Return randomized expires between expires-range% and expires.
+ * RFC allows only value less or equal to the one provided by UAC.
+ */
+static inline int randomize_expires( int expires, int range )
+{
+ /* if no range is given just return expires */
+ if(range == 0) return expires;
+
+ int range_min = expires - (float)range/100 * expires;
+
+ return range_min + (float)(rand()%100)/100 * ( expires - range_min );
+}
+
+
/*! \brief
* Calculate absolute expires value per contact as follows:
* 1) If the contact has expires value, use the value. If it
@@ -124,6 +140,9 @@ static inline int calc_contact_expires(contact_t *c, unsigned int expires_hdr, i
r = default_registrar_cfg.em_min_expires;
end:
+
+ r = randomize_expires(r, default_registrar_cfg.default_expires_range);
+
LM_DBG("Calculated expires for contact is %d\n", r);
return time(NULL) + r;
}
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task is now closed:
FS#482 - deadlock if calling t_check_trans() from failure route
User who did this - Daniel-Constantin Mierla (miconda)
Reason for closing: Fixed
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=482
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#482 - deadlock if calling t_check_trans() from failure route
User who did this - Daniel-Constantin Mierla (miconda)
----------
Pushed a patch to master to catch when using t_check_trans() inside a tm routing block. Test and see if all goes ok with it.
----------
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=482#comment1685
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
Module: sip-router
Branch: master
Commit: a8d50919bd614b704f3a4e08ff90d844b2c29829
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a8d5091…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Oct 30 11:41:41 2014 +0100
tm: safety catch inside t_check_trans() when already in a tm routing block
- transaction is known and some of these routing blocks are inside tm
lock, which can result in deadlock if not tested
- reported by Andrew Pogrebennyk, FS#482
---
modules/tm/tm.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/modules/tm/tm.c b/modules/tm/tm.c
index f3568c1..d437119 100644
--- a/modules/tm/tm.c
+++ b/modules/tm/tm.c
@@ -2140,6 +2140,13 @@ int t_check_trans(struct sip_msg* msg)
int branch;
int ret;
+ /* already processing a T */
+ if(get_route_type()==FAILURE_ROUTE
+ || get_route_type()==BRANCH_ROUTE
+ || get_route_type()==TM_ONREPLY_ROUTE) {
+ return 1;
+ }
+
if (msg->first_line.type==SIP_REPLY) {
branch = 0;
ret = (t_check_msg( msg , &branch)==1) ? 1 : -1;
@@ -2171,7 +2178,7 @@ int t_check_trans(struct sip_msg* msg)
}
/* no need for UNREF(t); set_t(0) - the end-of-script
t_unref callback will take care of them */
- return 0; /* return from the script */
+ return 0; /* exit from the script */
}
/* not found or error */
}
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task is now closed:
FS#487 - sqlops sql_pvquery() error
User who did this - Daniel-Constantin Mierla (miconda)
Reason for closing: Fixed
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=487
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task is now closed:
FS#486 - htable segfault
User who did this - Daniel-Constantin Mierla (miconda)
Reason for closing: Fixed
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=486
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#486 - htable segfault
User who did this - Daniel-Constantin Mierla (miconda)
----------
This shouldn't happen as the database schema creates the table with the column type string. I pushed the safety check given that it is not affecting performances at runtime.
----------
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=486#comment1684
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.