Module: sip-router
Branch: master
Commit: d877c3ac0576fe9a0aea1262c6ec05eb7eb26e3e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d877c3a…
Author: Carsten Bock <carsten(a)ng-voice.com>
Committer: Carsten Bock <carsten(a)ng-voice.com>
Date: Fri Jul 18 19:17:00 2014 +0800
ims_usrloc_scscf: Bugfix/Improvement: Use "last-inserted ID" instead of doing a
separate query (may cause issues with Replication/Database-Clusters)
---
modules/ims_usrloc_scscf/usrloc_db.c | 22 +---------------------
1 files changed, 1 insertions(+), 21 deletions(-)
diff --git a/modules/ims_usrloc_scscf/usrloc_db.c b/modules/ims_usrloc_scscf/usrloc_db.c
index 044ca98..49b551b 100644
--- a/modules/ims_usrloc_scscf/usrloc_db.c
+++ b/modules/ims_usrloc_scscf/usrloc_db.c
@@ -251,27 +251,7 @@ int db_insert_ucontact(impurecord_t* _r, ucontact_t* _c) {
LM_ERR("Failed to insert/update contact record for [%.*s]\n", _c->c.len,
_c->c.s);
return -1;
}
- /* search for the ID if the contact just entered */
- if (ul_dbf.query(ul_dbh, key, 0, val, key_return, 1, 1, NULL, &_rs) != 0) {
- LM_ERR("Unable to find contact [%.*s] in DB to complete IMPU-contact
mapping\n", _c->c.len, _c->c.s);
- ul_dbf.free_result(ul_dbh, _rs);
- return -1;
- }
-
- if (RES_ROW_N(_rs) == 0) {
- LM_DBG("Contact %.*s not found in DB\n",_c->c.len, _c->c.s);
- ul_dbf.free_result(ul_dbh, _rs);
- return -1;
- }
-
- if (RES_ROW_N(_rs) > 1) {
- LM_WARN("more than one contact found in DB for contact [%.*s] - this should not
happen... proceeding with first entry\n",
- _c->c.len, _c->c.s);
- }
-
- ret_val = ROW_VALUES(RES_ROWS(_rs));
- contact_id = ret_val[0].val.int_val;
- ul_dbf.free_result(ul_dbh, _rs);
+ contact_id = ul_dbf.last_inserted_id(ul_dbh);
LM_DBG("contact ID is %d\n", contact_id);
/* search for ID of the associated IMPU */