2
0
Эх сурвалжийг харах

usrloc: avoid double locking when preloading attributes

- reported by Seudin Kasumovic, FS#378
Daniel-Constantin Mierla 11 жил өмнө
parent
commit
888635bfa3

+ 3 - 3
modules/usrloc/udomain.c

@@ -1270,8 +1270,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);
@@ -1287,8 +1286,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)) {