Skip to content

Commit 6b8cfb5

Browse files
committed
Allow use of per-thread libctx test to share ssl ctx'es
We have the ability to use a per thread libctx object with the -p option, but when we do, we always re-create an ssl-ctx for the client and server, unlike the other modes in which we allow the -s option to re-use ssl-ctxes We should allow reuse in all test cases to make closer comparisons between test modes (libctx pool, single libctx and libctx-per-thread) Add recognition of the -s sharing option to the -p per-thread-libctx mode Reviewed-by: Saša Nedvědický <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from #35)
1 parent c58c9bd commit 6b8cfb5

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

source/handshake.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,17 @@ static void do_handshake_ossl_lib_ctx_per_thread(size_t num)
124124
counts[num] = 0;
125125

126126
do {
127-
if (!perflib_create_ossl_lib_ctx_pair(libctx,
128-
TLS_server_method(),
129-
TLS_client_method(),
130-
0, 0, &lsctx, &lcctx, cert,
131-
privkey)) {
132-
ERR_print_errors_fp(stderr);
133-
fprintf(stderr, "%s:%d: Failed to create SSL_CTX pair\n", __FILE__, __LINE__);
134-
err = 1;
135-
return;
127+
if (lsctx == NULL) {
128+
if (!perflib_create_ossl_lib_ctx_pair(libctx,
129+
TLS_server_method(),
130+
TLS_client_method(),
131+
0, 0, &lsctx, &lcctx, cert,
132+
privkey)) {
133+
ERR_print_errors_fp(stderr);
134+
fprintf(stderr, "%s:%d: Failed to create SSL_CTX pair\n", __FILE__, __LINE__);
135+
err = 1;
136+
return;
137+
}
136138
}
137139

138140

@@ -142,13 +144,18 @@ static void do_handshake_ossl_lib_ctx_per_thread(size_t num)
142144
SSL_ERROR_NONE);
143145
perflib_shutdown_ssl_connection(serverssl, clientssl);
144146
serverssl = clientssl = NULL;
145-
SSL_CTX_free(lsctx);
146-
SSL_CTX_free(lcctx);
147-
lsctx = lcctx = NULL;
147+
if (share_ctx == 0) {
148+
SSL_CTX_free(lsctx);
149+
SSL_CTX_free(lcctx);
150+
lsctx = lcctx = NULL;
151+
}
148152
counts[num]++;
149153
time = ossl_time_now();
150154
} while (time.t < max_time.t);
151155

156+
SSL_CTX_free(lsctx);
157+
SSL_CTX_free(lcctx);
158+
152159
if (!ret)
153160
err = 1;
154161

0 commit comments

Comments
 (0)