+CssmClient::Db
+StorageManager::makeDb(DLDbIdentifier dLDbIdentifier) {
+ Module module(dLDbIdentifier.ssuid().guid());
+
+ DL dl;
+ if (dLDbIdentifier.ssuid().subserviceType() & CSSM_SERVICE_CSP)
+ dl = SSCSPDL(module);
+ else
+ dl = DL(module);
+
+ dl->subserviceId(dLDbIdentifier.ssuid().subserviceId());
+ dl->version(dLDbIdentifier.ssuid().version());
+
+ CssmClient::Db db(dl, dLDbIdentifier.dbName());
+
+ return db;
+}
+
+void
+StorageManager::reloadKeychain(Keychain keychain) {
+ StLock<Mutex>_(mKeychainMapMutex);
+
+ DLDbIdentifier dLDbIdentifier = keychain->database()->dlDbIdentifier();
+
+ // Since we're going to reload this database and switch over the keychain's
+ // mDb, grab its mDb mutex
+ {
+ StLock<Mutex>__(keychain->mDbMutex);
+
+ CssmClient::Db db(makeDb(dLDbIdentifier));
+ keychain->mDb = db;
+ }
+
+ // Since this new database is based on the exact same dLDbIdentifier, we
+ // don't need to update the mKeychains map.
+}
+