Browse code

usrloc: avoid double locking when preloading attributes

- reported by Seudin Kasumovic, FS#378

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

Daniel-Constantin Mierla authored on 09/12/2013 09:06:15
Showing 1 changed files
... ...
@@ -1265,8 +1265,7 @@ int uldb_preload_attrs(udomain_t *_d)
1265 1265
 				suri = user;
1266 1266
 			}
1267 1267
 
1268
-			lock_udomain(_d, &suri);
1269
-			if (get_urecord_by_ruid(_d, ul_get_aorhash(&suri), &ruid, &r, &c) > 0) {
1268
+			if (get_urecord_by_ruid(_d, ul_get_aorhash(&suri), &ruid, &r, &c) < 0) {
1270 1269
 				/* delete attrs records from db table */
1271 1270
 				LM_INFO("no contact record for this ruid\n");
1272 1271
 				uldb_delete_attrs(_d->name, &user, &domain, &ruid);
... ...
@@ -1282,8 +1281,9 @@ int uldb_preload_attrs(udomain_t *_d)
1282 1281
 							LM_INFO("cannot add values to contact xavp\n");
1283 1282
 					}
1284 1283
 				}
1284
+				/* get_urecord_by_ruid() locks the slot */
1285
+				unlock_udomain(_d, &suri);
1285 1286
 			}
1286
-			unlock_udomain(_d, &user);
1287 1287
 		}
1288 1288
 
1289 1289
 		if (DB_CAPABILITY(ul_dbf, DB_CAP_FETCH)) {