Skip to content

Commit

Permalink
Improve custom SSL_CTX tests.
Browse files Browse the repository at this point in the history
Issue #2463.
  • Loading branch information
ralight committed Aug 12, 2022
1 parent 80c7726 commit 5d18962
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx-default.c
@@ -1,4 +1,5 @@
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -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){
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions test/lib/c/08-ssl-connect-cert-auth-custom-ssl-ctx.c
@@ -1,4 +1,5 @@
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -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){
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5d18962

Please sign in to comment.