[sr-dev] git:4.0: usrloc: avoid double locking when preloading attributes

Daniel-Constantin Mierla miconda at gmail.com
Fri Dec 20 12:41:54 CET 2013


Module: sip-router
Branch: 4.0
Commit: 2e08848cdb16fa717897b6b70fde4dc9ef3c34a5
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2e08848cdb16fa717897b6b70fde4dc9ef3c34a5

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Dec  9 10:06:15 2013 +0100

usrloc: avoid double locking when preloading attributes

- reported by Seudin Kasumovic, FS#378

(cherry picked from commit 888635bfa3719afeeea6f5f0d407aa862ceb34ac)
(cherry picked from commit 8df9d2336e7de2648288cf8ff6821e6820d88da9)

---

 modules/usrloc/udomain.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/usrloc/udomain.c b/modules/usrloc/udomain.c
index d3275b8..9eeb950 100644
--- a/modules/usrloc/udomain.c
+++ b/modules/usrloc/udomain.c
@@ -1265,8 +1265,7 @@ int uldb_preload_attrs(udomain_t *_d)
 				suri = user;
 			}
 
-			lock_udomain(_d, &suri);
-			if (get_urecord_by_ruid(_d, ul_get_aorhash(&suri), &ruid, &r, &c) > 0) {
+			if (get_urecord_by_ruid(_d, ul_get_aorhash(&suri), &ruid, &r, &c) < 0) {
 				/* delete attrs records from db table */
 				LM_INFO("no contact record for this ruid\n");
 				uldb_delete_attrs(_d->name, &user, &domain, &ruid);
@@ -1282,8 +1281,9 @@ int uldb_preload_attrs(udomain_t *_d)
 							LM_INFO("cannot add values to contact xavp\n");
 					}
 				}
+				/* get_urecord_by_ruid() locks the slot */
+				unlock_udomain(_d, &suri);
 			}
-			unlock_udomain(_d, &user);
 		}
 
 		if (DB_CAPABILITY(ul_dbf, DB_CAP_FETCH)) {




More information about the sr-dev mailing list