From 94b36d99ce670732013e2ee50a7e7ca6ccf766ee Mon Sep 17 00:00:00 2001 From: Kaleb Himes Date: Tue, 3 Jun 2014 16:14:23 -0600 Subject: [PATCH] sig init handles client connection fail --- .../server-dtls-nonblocking.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/project1/dtls_secured_nonblocking/server-dtls-nonblocking.c b/project1/dtls_secured_nonblocking/server-dtls-nonblocking.c index a0e4ecdc..b54865f2 100644 --- a/project1/dtls_secured_nonblocking/server-dtls-nonblocking.c +++ b/project1/dtls_secured_nonblocking/server-dtls-nonblocking.c @@ -61,6 +61,8 @@ void sig_handler(const int sig) { printf("\nSIGINT handled.\n"); cleanup = 1; + CyaSSL_CTX_free(ctx); + CyaSSL_Cleanup(); } void AwaitDGram() @@ -71,11 +73,6 @@ void AwaitDGram() while (cleanup != 1) { - if (cleanup == 1) { - CyaSSL_CTX_free(ctx); - CyaSSL_Cleanup(); - } - /* Create a UDP/IP socket */ if ( (listenfd = socket(AF_INET, SOCK_DGRAM, 0) ) < 0 ) { printf("Cannot create socket.\n"); @@ -148,8 +145,7 @@ void AwaitDGram() readWriteErr = CyaSSL_get_error(ssl, 0); do { if (cleanup == 1) { - CyaSSL_CTX_free(ctx); - CyaSSL_Cleanup(); + break; } if (recvlen < 0) { readWriteErr = CyaSSL_get_error(ssl, 0); @@ -205,8 +201,7 @@ static void NonBlockingSSL_Accept(CYASSL* ssl) (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE))) { if (cleanup == 1) { - CyaSSL_CTX_free(ctx); - CyaSSL_Cleanup(); + break; } int currTimeout = 1;