sig init handles client connection fail

pull/1/head
Kaleb Himes 2014-06-03 16:14:23 -06:00
parent e1c32dc77b
commit 94b36d99ce
1 changed files with 4 additions and 9 deletions

View File

@ -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;