зеркало из https://github.com/mozilla/gecko-dev.git
Bug 988881: clean up CryptoTask (SignedJar) tasks instead of leaking them r=bsmedberg,mayhemer
This commit is contained in:
Родитель
1602115e41
Коммит
302ba02d64
|
@ -18,17 +18,6 @@ CryptoTask::~CryptoTask()
|
|||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
CryptoTask::Dispatch(const nsACString & taskThreadName)
|
||||
{
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewThread(getter_AddRefs(thread), this);
|
||||
if (thread) {
|
||||
NS_SetThreadName(thread, taskThreadName);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CryptoTask::Run()
|
||||
{
|
||||
|
@ -52,6 +41,13 @@ CryptoTask::Run()
|
|||
}
|
||||
|
||||
CallCallback(mRv);
|
||||
|
||||
// Not all uses of CryptoTask use a transient thread
|
||||
if (mThread) {
|
||||
// Don't leak threads!
|
||||
mThread->Shutdown(); // can't Shutdown from the thread itself, darn
|
||||
mThread = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -39,7 +39,12 @@ public:
|
|||
{
|
||||
static_assert(LEN <= 15,
|
||||
"Thread name must be no more than 15 characters");
|
||||
return Dispatch(nsDependentCString(taskThreadName));
|
||||
// Can't add 'this' as the event to run, since mThread may not be set yet
|
||||
nsresult rv = NS_NewNamedThread(taskThreadName, getter_AddRefs(mThread));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mThread->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -76,10 +81,10 @@ private:
|
|||
NS_IMETHOD Run() MOZ_OVERRIDE MOZ_FINAL;
|
||||
virtual void virtualDestroyNSSReference() MOZ_OVERRIDE MOZ_FINAL;
|
||||
|
||||
nsresult Dispatch(const nsACString & taskThreadName);
|
||||
|
||||
nsresult mRv;
|
||||
bool mReleasedNSSResources;
|
||||
|
||||
nsCOMPtr<nsIThread> mThread;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче