2001-08-15 05:53:53 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-31 13:33:35 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2017-01-02 09:11:39 +03:00
|
|
|
#include "PSMRunnable.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/DebugOnly.h"
|
2001-08-15 05:53:53 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2004-11-24 23:17:25 +03:00
|
|
|
#include "nsIObserver.h"
|
2017-01-02 09:11:39 +03:00
|
|
|
#include "nsKeygenThread.h"
|
2003-01-18 17:03:00 +03:00
|
|
|
#include "nsNSSShutDown.h"
|
2017-01-02 09:11:39 +03:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "pk11func.h"
|
2001-08-15 05:53:53 +04:00
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
using namespace mozilla;
|
2011-11-03 08:14:33 +04:00
|
|
|
using namespace mozilla::psm;
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsKeygenThread, nsIKeygenThread)
|
2001-08-15 05:53:53 +04:00
|
|
|
|
|
|
|
|
|
|
|
nsKeygenThread::nsKeygenThread()
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
:mutex("nsKeygenThread.mutex"),
|
2011-10-17 18:59:28 +04:00
|
|
|
iAmRunning(false),
|
|
|
|
keygenReady(false),
|
|
|
|
statusDialogClosed(false),
|
|
|
|
alreadyReceivedParams(false),
|
2012-07-30 18:20:58 +04:00
|
|
|
privateKey(nullptr),
|
|
|
|
publicKey(nullptr),
|
|
|
|
slot(nullptr),
|
2012-03-22 02:22:15 +04:00
|
|
|
flags(0),
|
2012-07-30 18:20:58 +04:00
|
|
|
altSlot(nullptr),
|
2012-03-22 02:22:15 +04:00
|
|
|
altFlags(0),
|
2012-07-30 18:20:58 +04:00
|
|
|
usedSlot(nullptr),
|
2001-10-23 10:11:57 +04:00
|
|
|
keyGenMechanism(0),
|
2012-07-30 18:20:58 +04:00
|
|
|
params(nullptr),
|
|
|
|
wincx(nullptr),
|
|
|
|
threadHandle(nullptr)
|
2001-08-15 05:53:53 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsKeygenThread::~nsKeygenThread()
|
|
|
|
{
|
2012-03-22 02:22:15 +04:00
|
|
|
// clean up in the unlikely case that nobody consumed our results
|
|
|
|
|
|
|
|
if (privateKey)
|
|
|
|
SECKEY_DestroyPrivateKey(privateKey);
|
|
|
|
|
|
|
|
if (publicKey)
|
|
|
|
SECKEY_DestroyPublicKey(publicKey);
|
|
|
|
|
|
|
|
if (usedSlot)
|
|
|
|
PK11_FreeSlot(usedSlot);
|
2001-10-23 10:11:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsKeygenThread::SetParams(
|
|
|
|
PK11SlotInfo *a_slot,
|
2012-03-22 02:22:15 +04:00
|
|
|
PK11AttrFlags a_flags,
|
|
|
|
PK11SlotInfo *a_alternative_slot,
|
|
|
|
PK11AttrFlags a_alternative_flags,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t a_keyGenMechanism,
|
2001-10-23 10:11:57 +04:00
|
|
|
void *a_params,
|
|
|
|
void *a_wincx )
|
|
|
|
{
|
2003-01-18 17:03:00 +03:00
|
|
|
nsNSSShutDownPreventionLock locker;
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mutex);
|
2001-10-23 10:11:57 +04:00
|
|
|
|
|
|
|
if (!alreadyReceivedParams) {
|
2011-10-17 18:59:28 +04:00
|
|
|
alreadyReceivedParams = true;
|
2012-07-30 18:20:58 +04:00
|
|
|
slot = (a_slot) ? PK11_ReferenceSlot(a_slot) : nullptr;
|
2012-03-22 02:22:15 +04:00
|
|
|
flags = a_flags;
|
2012-07-30 18:20:58 +04:00
|
|
|
altSlot = (a_alternative_slot) ? PK11_ReferenceSlot(a_alternative_slot) : nullptr;
|
2012-03-22 02:22:15 +04:00
|
|
|
altFlags = a_alternative_flags;
|
2001-10-23 10:11:57 +04:00
|
|
|
keyGenMechanism = a_keyGenMechanism;
|
|
|
|
params = a_params;
|
|
|
|
wincx = a_wincx;
|
|
|
|
}
|
2001-08-15 05:53:53 +04:00
|
|
|
}
|
|
|
|
|
2012-03-22 02:22:15 +04:00
|
|
|
nsresult nsKeygenThread::ConsumeResult(
|
|
|
|
PK11SlotInfo **a_used_slot,
|
2001-10-23 10:11:57 +04:00
|
|
|
SECKEYPrivateKey **a_privateKey,
|
|
|
|
SECKEYPublicKey **a_publicKey)
|
2001-08-15 05:53:53 +04:00
|
|
|
{
|
2012-03-22 02:22:15 +04:00
|
|
|
if (!a_used_slot || !a_privateKey || !a_publicKey) {
|
2001-10-23 10:11:57 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv;
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
|
|
|
|
MutexAutoLock lock(mutex);
|
2001-10-23 10:11:57 +04:00
|
|
|
|
|
|
|
// GetParams must not be called until thread creator called
|
|
|
|
// Join on this thread.
|
2017-01-02 09:11:39 +03:00
|
|
|
MOZ_ASSERT(keygenReady, "Logic error in nsKeygenThread::GetParams");
|
2001-10-23 10:11:57 +04:00
|
|
|
|
|
|
|
if (keygenReady) {
|
|
|
|
*a_privateKey = privateKey;
|
|
|
|
*a_publicKey = publicKey;
|
2012-03-22 02:22:15 +04:00
|
|
|
*a_used_slot = usedSlot;
|
2001-10-23 10:11:57 +04:00
|
|
|
|
|
|
|
privateKey = 0;
|
|
|
|
publicKey = 0;
|
2012-03-22 02:22:15 +04:00
|
|
|
usedSlot = 0;
|
2001-10-23 10:11:57 +04:00
|
|
|
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
2001-08-15 05:53:53 +04:00
|
|
|
}
|
|
|
|
|
2012-09-25 20:18:38 +04:00
|
|
|
static void nsKeygenThreadRunner(void *arg)
|
2001-08-21 18:22:11 +04:00
|
|
|
{
|
2012-06-12 21:06:20 +04:00
|
|
|
PR_SetCurrentThreadName("Keygen");
|
2007-07-08 11:08:04 +04:00
|
|
|
nsKeygenThread *self = static_cast<nsKeygenThread *>(arg);
|
2001-08-21 18:22:11 +04:00
|
|
|
self->Run();
|
|
|
|
}
|
|
|
|
|
2004-11-24 23:17:25 +03:00
|
|
|
nsresult nsKeygenThread::StartKeyGeneration(nsIObserver* aObserver)
|
2001-08-15 05:53:53 +04:00
|
|
|
{
|
2011-11-03 08:14:33 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NS_ERROR("nsKeygenThread::StartKeyGeneration called off the main thread");
|
|
|
|
return NS_ERROR_NOT_SAME_THREAD;
|
|
|
|
}
|
|
|
|
|
2004-11-24 23:17:25 +03:00
|
|
|
if (!aObserver)
|
2001-08-15 05:53:53 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mutex);
|
2001-08-15 05:53:53 +04:00
|
|
|
|
|
|
|
if (iAmRunning || keygenReady) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-03 08:14:33 +04:00
|
|
|
// We must AddRef aObserver only here on the main thread, because it
|
|
|
|
// probably does not implement a thread-safe AddRef.
|
|
|
|
mNotifyObserver = new NotifyObserverRunnable(aObserver, "keygen-finished");
|
2001-10-23 10:11:57 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
iAmRunning = true;
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
threadHandle = PR_CreateThread(PR_USER_THREAD, nsKeygenThreadRunner, static_cast<void*>(this),
|
2014-04-04 06:29:40 +04:00
|
|
|
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
// bool thread_started_ok = (threadHandle != nullptr);
|
2001-08-15 05:53:53 +04:00
|
|
|
// we might want to return "thread started ok" to caller in the future
|
2017-01-02 09:11:39 +03:00
|
|
|
MOZ_ASSERT(threadHandle, "Could not create nsKeygenThreadRunner thread");
|
2001-08-15 05:53:53 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult nsKeygenThread::UserCanceled(bool *threadAlreadyClosedDialog)
|
2001-08-15 05:53:53 +04:00
|
|
|
{
|
2006-04-20 20:21:26 +04:00
|
|
|
if (!threadAlreadyClosedDialog)
|
|
|
|
return NS_OK;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
*threadAlreadyClosedDialog = false;
|
2001-08-15 05:53:53 +04:00
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mutex);
|
2001-08-15 05:53:53 +04:00
|
|
|
|
|
|
|
if (keygenReady)
|
|
|
|
*threadAlreadyClosedDialog = statusDialogClosed;
|
|
|
|
|
|
|
|
// User somehow closed the dialog, but we will not cancel.
|
|
|
|
// Bad luck, we told him not do, and user still has to wait.
|
|
|
|
// However, we remember that it's closed and will not close
|
|
|
|
// it again to avoid problems.
|
2011-10-17 18:59:28 +04:00
|
|
|
statusDialogClosed = true;
|
2001-08-15 05:53:53 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-08-21 18:22:11 +04:00
|
|
|
void nsKeygenThread::Run(void)
|
2001-08-15 05:53:53 +04:00
|
|
|
{
|
2003-01-18 17:03:00 +03:00
|
|
|
nsNSSShutDownPreventionLock locker;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool canGenerate = false;
|
2001-08-15 05:53:53 +04:00
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
{
|
|
|
|
MutexAutoLock lock(mutex);
|
2001-10-23 10:11:57 +04:00
|
|
|
if (alreadyReceivedParams) {
|
2011-10-17 18:59:28 +04:00
|
|
|
canGenerate = true;
|
|
|
|
keygenReady = false;
|
2001-08-15 05:53:53 +04:00
|
|
|
}
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
}
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2012-03-22 02:22:15 +04:00
|
|
|
if (canGenerate) {
|
|
|
|
privateKey = PK11_GenerateKeyPairWithFlags(slot, keyGenMechanism,
|
|
|
|
params, &publicKey,
|
|
|
|
flags, wincx);
|
|
|
|
|
|
|
|
if (privateKey) {
|
|
|
|
usedSlot = PK11_ReferenceSlot(slot);
|
|
|
|
}
|
|
|
|
else if (altSlot) {
|
|
|
|
privateKey = PK11_GenerateKeyPairWithFlags(altSlot, keyGenMechanism,
|
|
|
|
params, &publicKey,
|
|
|
|
altFlags, wincx);
|
|
|
|
if (privateKey) {
|
|
|
|
usedSlot = PK11_ReferenceSlot(altSlot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-15 05:53:53 +04:00
|
|
|
|
|
|
|
// This call gave us ownership over privateKey and publicKey.
|
|
|
|
// But as the params structure is owner by our caller,
|
|
|
|
// we effectively transferred ownership to the caller.
|
|
|
|
// As long as key generation can't be canceled, we don't need
|
|
|
|
// to care for cleaning this up.
|
|
|
|
|
2011-11-03 08:14:33 +04:00
|
|
|
nsCOMPtr<nsIRunnable> notifyObserver;
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
{
|
|
|
|
MutexAutoLock lock(mutex);
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
keygenReady = true;
|
|
|
|
iAmRunning = false;
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2001-10-23 10:11:57 +04:00
|
|
|
// forget our parameters
|
|
|
|
if (slot) {
|
|
|
|
PK11_FreeSlot(slot);
|
|
|
|
slot = 0;
|
|
|
|
}
|
2012-03-22 02:22:15 +04:00
|
|
|
if (altSlot) {
|
|
|
|
PK11_FreeSlot(altSlot);
|
|
|
|
altSlot = 0;
|
|
|
|
}
|
2001-10-23 10:11:57 +04:00
|
|
|
keyGenMechanism = 0;
|
|
|
|
params = 0;
|
|
|
|
wincx = 0;
|
|
|
|
|
2011-11-03 08:14:33 +04:00
|
|
|
if (!statusDialogClosed && mNotifyObserver)
|
|
|
|
notifyObserver = mNotifyObserver;
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mNotifyObserver = nullptr;
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
}
|
2001-08-15 05:53:53 +04:00
|
|
|
|
2011-11-03 08:14:33 +04:00
|
|
|
if (notifyObserver) {
|
2013-06-24 11:57:51 +04:00
|
|
|
DebugOnly<nsresult> rv = NS_DispatchToMainThread(notifyObserver);
|
2017-01-02 09:11:39 +03:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
|
|
|
"Failed to dispatch keygen thread observer to main thread");
|
2011-11-03 08:14:33 +04:00
|
|
|
}
|
2001-08-15 05:53:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsKeygenThread::Join()
|
|
|
|
{
|
|
|
|
if (!threadHandle)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PR_JoinThread(threadHandle);
|
2012-07-30 18:20:58 +04:00
|
|
|
threadHandle = nullptr;
|
2001-08-15 05:53:53 +04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|