Skip to content

Commit 3ebca29

Browse files
Refactored Windows multithreaded private key read access test to minimize function size.
1 parent 34fda82 commit 3ebca29

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

test/test_dh.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -360,32 +360,16 @@ static DWORD WINAPI DhKeyGenThreadFunc(LPVOID arg)
360360
threads do not */
361361
int test_dh_key_gen_multithreaded(ENGINE* e, EVP_PKEY* params)
362362
{
363-
DH_KEYGEN_THREAD_VARS vars;
364-
HANDLE hThread;
365-
DWORD dwThreadId;
366-
DWORD dwThreadErr = 0;
367-
int err = 0;
368-
369-
vars.e = e;
370-
vars.params = params;
371-
372-
hThread = CreateThread(NULL, 0, DhKeyGenThreadFunc, &vars, 0, &dwThreadId);
373-
if (hThread == NULL) {
374-
err = 1;
375-
}
376-
377-
if (err == 0) {
378-
WaitForSingleObject(hThread, INFINITE);
379-
if (GetExitCodeThread(hThread, &dwThreadErr) == 0) {
380-
err = 1;
381-
}
382-
else {
383-
err = dwThreadErr;
384-
}
385-
}
386-
387-
if (hThread != NULL) {
388-
CloseHandle(hThread);
363+
DH_KEYGEN_THREAD_VARS vars = {.e = e, .params = params};
364+
HANDLE thread;
365+
DWORD threadErr = 0;
366+
int err = 1;
367+
368+
thread = CreateThread(NULL, 0, DhKeyGenThreadFunc, &vars, 0, NULL);
369+
if (thread) {
370+
WaitForSingleObject(thread, INFINITE);
371+
err = (GetExitCodeThread(thread, &threadErr) == 0 ? 1 : threadErr);
372+
CloseHandle(thread);
389373
}
390374

391375
return err;

0 commit comments

Comments
 (0)