Browse Source

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 11 năm trước cách đây
mục cha
commit
2e08848cdb
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      modules/usrloc/udomain.c

+ 3 - 3
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)) {