From 5d18962486bf4cee693cc474ecb704021e03ada3 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Fri, 12 Aug 2022 08:52:40 +0100 Subject: [PATCH] Improve custom SSL_CTX tests. Issue #2463. --- .../c/08-ssl-connect-cert-auth-custom-ssl-ctx-default.c | 8 ++++++++ test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx-default.c b/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx-default.c index 2a0d5baf56..f92fcb9c22 100644 --- a/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx-default.c +++ b/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx-default.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -7,6 +8,11 @@ static int run = -1; +void handle_sigint(int signal) +{ + run = 0; +} + void on_connect(struct mosquitto *mosq, void *obj, int rc) { if(rc){ @@ -49,9 +55,11 @@ int main(int argc, char *argv[]) rc = mosquitto_connect(mosq, "localhost", port, 60); + signal(SIGINT, handle_sigint); while(run == -1){ mosquitto_loop(mosq, -1, 1); } + SSL_CTX_free(ssl_ctx); mosquitto_destroy(mosq); mosquitto_lib_cleanup(); diff --git a/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx.c b/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx.c index 5d9866efb8..e0fe94ef3a 100644 --- a/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx.c +++ b/test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -7,6 +8,11 @@ static int run = -1; +void handle_sigint(int signal) +{ + run = 0; +} + void on_connect(struct mosquitto *mosq, void *obj, int rc) { if(rc){ @@ -53,9 +59,11 @@ int main(int argc, char *argv[]) rc = mosquitto_connect(mosq, "localhost", port, 60); + signal(SIGINT, handle_sigint); while(run == -1){ mosquitto_loop(mosq, -1, 1); } + SSL_CTX_free(ssl_ctx); mosquitto_destroy(mosq); mosquitto_lib_cleanup();