Module: sip-router
Branch: master
Commit: d5b8c4f9091646597341e0d8dc08e2c3930f713a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d5b8c4f…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Fri Apr 20 16:11:48 2012 +0100
modules_k/rls: Updated module documentation and changed use of BEGIN/COMMIT so it only happens in database only mode
---
modules_k/rls/README | 9 +++++++++
modules_k/rls/doc/rls_admin.xml | 11 +++++++++++
modules_k/rls/notify.c | 18 ++++++++++++------
modules_k/rls/resource_notify.c | 18 ++++++++++++------
4 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/modules_k/rls/README b/modules_k/rls/README
index df3a879..40ebeae 100644
--- a/modules_k/rls/README
+++ b/modules_k/rls/README
@@ -259,6 +259,15 @@ modparam("rls", "xcap_db_url", "dbdriver://username:password@dbhost/dbname")
in a database, allowing scalability at the expense of speed. Mode 1 is
reserved.
+ The RLS modules uses SQL BEGIN/COMMIT statements around related sets of
+ database queries to make sure they are a single transaction when
+ database only mode is used. This means you should ensure that automatic
+ retries/reconnects are disabled for your database (for example, by
+ setting the retries parameter for db_mysql or db_postgres to 0). This
+ is needed because if the connection fails any unCOMMITed queries will
+ be automatically rolled back by the database. This means that automatic
+ retries could result in data inconsistencies.
+
Default value is “0”
Example 1.4. Set db_mode parameter
diff --git a/modules_k/rls/doc/rls_admin.xml b/modules_k/rls/doc/rls_admin.xml
index 0669b70..db03b9f 100644
--- a/modules_k/rls/doc/rls_admin.xml
+++ b/modules_k/rls/doc/rls_admin.xml
@@ -175,6 +175,17 @@ modparam("rls", "xcap_db_url", "&exampledb;")
Mode 1 is reserved.
</para>
<para>
+ The RLS modules uses SQL BEGIN/COMMIT statements around related
+ sets of database queries to make sure they are a single
+ transaction when database only mode is used. This means you
+ should ensure that automatic retries/reconnects are disabled
+ for your database (for example, by setting the retries
+ parameter for db_mysql or db_postgres to 0). This is needed
+ because if the connection fails any unCOMMITed queries will
+ be automatically rolled back by the database. This means that
+ automatic retries could result in data inconsistencies.
+ </para>
+ <para>
<emphasis> Default value is <quote>0</quote>
</emphasis>
</para>
diff --git a/modules_k/rls/notify.c b/modules_k/rls/notify.c
index 1836808..fbb7e17 100644
--- a/modules_k/rls/notify.c
+++ b/modules_k/rls/notify.c
@@ -128,10 +128,13 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri,
goto error;
}
- if (db_begin(&rlpres_dbf, rlpres_db) < 0)
+ if (dbmode == RLS_DB_ONLY)
{
- LM_ERR("in BEGIN\n");
- goto error;
+ if (db_begin(&rlpres_dbf, rlpres_db) < 0)
+ {
+ LM_ERR("in BEGIN\n");
+ goto error;
+ }
}
if(rlpres_dbf.query(rlpres_db, query_cols, 0, query_vals, result_cols,
@@ -263,10 +266,13 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri,
goto error;
}
- if (db_commit(&rlpres_dbf, rlpres_db) < 0)
+ if (dbmode == RLS_DB_ONLY)
{
- LM_ERR("in COMMIT\n");
- goto error;
+ if (db_commit(&rlpres_dbf, rlpres_db) < 0)
+ {
+ LM_ERR("in COMMIT\n");
+ goto error;
+ }
}
xmlFree(rlmi_cont->s);
diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c
index 87ce806..910b098 100644
--- a/modules_k/rls/resource_notify.c
+++ b/modules_k/rls/resource_notify.c
@@ -1037,10 +1037,13 @@ static void timer_send_update_notifies(int round)
goto done;
}
- if (db_begin(&rlpres_dbf, rlpres_db) < 0)
+ if (dbmode == RLS_DB_ONLY)
{
- LM_ERR("in BEGIN\n");
- goto error;
+ if (db_begin(&rlpres_dbf, rlpres_db) < 0)
+ {
+ LM_ERR("in BEGIN\n");
+ goto error;
+ }
}
if(rlpres_dbf.query(rlpres_db, query_cols, 0, query_vals, result_cols,
@@ -1060,10 +1063,13 @@ static void timer_send_update_notifies(int round)
goto error;
}
- if (db_commit(&rlpres_dbf, rlpres_db) < 0)
+ if (dbmode == RLS_DB_ONLY)
{
- LM_ERR("in COMMIT\n");
- goto error;
+ if (db_commit(&rlpres_dbf, rlpres_db) < 0)
+ {
+ LM_ERR("in COMMIT\n");
+ goto error;
+ }
}
send_notifies(result, did_col, resource_uri_col, auth_state_col, reason_col,
Module: sip-router
Branch: master
Commit: 0220bad8ca1a22d212324102d489bb22d3076abd
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0220bad…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Fri Apr 20 14:28:18 2012 +0100
modules_k/pua: Fixed bug in pua_update_contact() in DB only mode
- This was updating the contact column when it should have been
updating the remote_contact column.
---
modules_k/pua/pua_db.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules_k/pua/pua_db.c b/modules_k/pua/pua_db.c
index 2bc9e88..200e951 100644
--- a/modules_k/pua/pua_db.c
+++ b/modules_k/pua/pua_db.c
@@ -1407,7 +1407,7 @@ int update_contact_puadb(ua_pres_t *pres, str *contact)
n_query_cols++;
/* we overwrite contact even if not changed */
- db_cols[n_update_cols] = &str_contact_col; /* had remote here, think was a bug */
+ db_cols[n_update_cols] = &str_remote_contact_col;
db_vals[n_update_cols].type = DB1_STR;
db_vals[n_update_cols].nul = 0;
db_vals[n_update_cols].val.str_val.s = contact->s;
@@ -1566,4 +1566,4 @@ list_entry_t *get_subs_list_puadb(str *did)
&& (RES_ROWS(res)>0));
return list;
-}
\ No newline at end of file
+}
Hello,
a short reminder about freezing the development for next major release
v3.3.0. It is planned for April 23, less than two weeks away. If you
have new features to add for v3.3.0, commit them or send the patches
before the date.
Cheers,
Daniel
--
Daniel-Constantin Mierla
Kamailio Advanced Training, April 23-26, 2012, Berlin, Germany
http://www.asipto.com/index.php/kamailio-advanced-training/
Hello,
I have a question about random number generation within kamailio.
A number of modules use rand() to get a random value and in some places
is re-seeding with srand(). I believe this is dangerous because rand()
is used in the Via branch tag generator.
We have detected some real bugs (where srand is reseeding with 0 for
every message, causing transaction mis-matching) but I'm not sure of the
correct way to fix this (other than remove srand()).
Should all modules be using a 'core' random function (e.g. in srutils?)
? And if so, is this library documented?
Regards,
Hugh
--
Hugh Waite
Senior Design Engineer
Crocodile RCS Ltd.