Fixes obvious portability error, moving thread starter function from C++ static method to C function.
No change in logic or functionality.
You can reach me at kai.engert@gmx.de
This commit is contained in:
kaie%netscape.com 2001-08-21 14:22:11 +00:00
Родитель b8f1b52da9
Коммит 537e8b6fba
2 изменённых файлов: 23 добавлений и 24 удалений

Просмотреть файл

@ -52,6 +52,12 @@ void nsKeygenThread::SetParams(GenerateKeypairParameters *p)
PR_Unlock(mutex);
}
static void PR_CALLBACK nsKeygenThreadRunner(void *arg)
{
nsKeygenThread *self = NS_STATIC_CAST(nsKeygenThread *, arg);
self->Run();
}
nsresult nsKeygenThread::StartKeyGeneration(nsIDOMWindowInternal *statusDialog)
{
if (!mutex)
@ -84,7 +90,7 @@ nsresult nsKeygenThread::StartKeyGeneration(nsIDOMWindowInternal *statusDialog)
iAmRunning = PR_TRUE;
threadHandle = PR_CreateThread(PR_USER_THREAD, run, NS_STATIC_CAST(void*, this),
threadHandle = PR_CreateThread(PR_USER_THREAD, nsKeygenThreadRunner, NS_STATIC_CAST(void*, this),
PR_PRIORITY_LOW, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
// bool thread_started_ok = (threadHandle != nsnull);
@ -120,26 +126,19 @@ nsresult nsKeygenThread::UserCanceled(PRBool *threadAlreadyClosedDialog)
return NS_OK;
}
void nsKeygenThread::run(void *args)
void nsKeygenThread::Run(void)
{
if (!args)
return;
nsKeygenThread *self = NS_STATIC_CAST(nsKeygenThread *, args);
if (!self)
return;
GenerateKeypairParameters *p = 0;
PR_Lock(self->mutex);
PR_Lock(mutex);
if (self->params) {
p = self->params;
if (params) {
p = params;
// Make sure it's impossible that will use the same parameters again.
self->params = 0;
params = 0;
}
PR_Unlock(self->mutex);
PR_Unlock(mutex);
if (p)
p->privateKey = PK11_GenerateKeyPair(p->slot, p->keyGenMechanism,
@ -154,18 +153,18 @@ void nsKeygenThread::run(void *args)
nsIDOMWindowInternal *windowToClose = 0;
PR_Lock(self->mutex);
PR_Lock(mutex);
self->keygenReady = PR_TRUE;
self->iAmRunning = PR_FALSE;
keygenReady = PR_TRUE;
iAmRunning = PR_FALSE;
if (!self->statusDialogClosed)
windowToClose = self->statusDialogPtr;
if (!statusDialogClosed)
windowToClose = statusDialogPtr;
self->statusDialogPtr = 0;
self->statusDialogClosed = PR_TRUE;
statusDialogPtr = 0;
statusDialogClosed = PR_TRUE;
PR_Unlock(self->mutex);
PR_Unlock(mutex);
if (windowToClose)
windowToClose->Close();

Просмотреть файл

@ -46,8 +46,6 @@ private:
PRBool keygenReady;
PRBool statusDialogClosed;
static void run(void *args);
PRThread *threadHandle;
GenerateKeypairParameters *params;
@ -65,6 +63,8 @@ public:
void SetParams(GenerateKeypairParameters *p);
void Join(void);
void Run(void);
};
#endif //_NSKEYGENTHREAD_H_