nsresult rv = NS_OK; PR_CEnterMonitor(this);  nsIDKey key(aClass); nsServiceEntry* entry = (nsServiceEntry*)mServices->Get(&key);  NS_ASSERTION(entry, "service not found"); NS_ASSERTION(entry->mService == service, "service looked failed");  if (entry) { rv = entry->RemoveListener(shutdownListener); nsrefcnt cnt; NS_RELEASE2(service, cnt); if (NS_SUCCEEDED(rv) && cnt == 0) { mServices->Remove(&key); delete entry; rv = nsComponentManager::FreeLibraries(); } }  PR_CExitMonitor(this); return rv;
nsCID aClass; nsresult rv; rv = nsComponentManager::ProgIDToCLSID(aProgID, &aClass); if (NS_FAILED(rv)) return rv; return ReleaseService(aClass, service, shutdownListener);
nsServiceManagerImpl::ReleaseService(const nsCID& aClass, nsISupports* service,                                     nsIShutdownListener* shutdownListener){    nsresult rv = NS_OK;    PR_CEnterMonitor(this);    nsIDKey key(aClass);    nsServiceEntry* entry = (nsServiceEntry*)mServices->Get(&key);    NS_ASSERTION(entry, "service not found");    NS_ASSERTION(entry->mService == service, "service looked failed");    if (entry) {        rv = entry->RemoveListener(shutdownListener);        nsrefcnt cnt;        NS_RELEASE2(service, cnt);        if (NS_SUCCEEDED(rv) && cnt == 0) {            mServices->Remove(&key);            delete entry;            rv = nsComponentManager::FreeLibraries();        }    }    PR_CExitMonitor(this);    return rv;}