added additional memory free
parent
10f21a8c03
commit
5ad64e2c9a
|
@ -61,6 +61,10 @@ void AwaitDGram()
|
||||||
socklen_t clilen; /* length of address' */
|
socklen_t clilen; /* length of address' */
|
||||||
|
|
||||||
while (cleanup != 1) {
|
while (cleanup != 1) {
|
||||||
|
if (cleanup == 1){
|
||||||
|
CyaSSL_Cleanup();
|
||||||
|
CyaSSL_CTX_free(ctx);
|
||||||
|
}
|
||||||
if ( (listenfd = socket(AF_INET, SOCK_DGRAM, 0) ) < 0 ) {
|
if ( (listenfd = socket(AF_INET, SOCK_DGRAM, 0) ) < 0 ) {
|
||||||
printf("Cannot create socket.\n");
|
printf("Cannot create socket.\n");
|
||||||
cleanup = 1;
|
cleanup = 1;
|
||||||
|
@ -113,20 +117,18 @@ void AwaitDGram()
|
||||||
|
|
||||||
else if (connfd > 0) {
|
else if (connfd > 0) {
|
||||||
|
|
||||||
pthread_t threadID;
|
pthread_t threadID;
|
||||||
|
|
||||||
if (pthread_create(&threadID, NULL,
|
if (pthread_create(&threadID, NULL,
|
||||||
ThreadControl, (void *)&connfd) < 0) {
|
ThreadControl, (void *)&connfd) < 0) {
|
||||||
printf("pthread_create failed.\n");
|
printf("pthread_create failed.\n");
|
||||||
}
|
}
|
||||||
printf("Connection being re-routed to Thread Control.\n");
|
printf("Connection being re-routed to Thread Control.\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Recvfrom failed.\n");
|
printf("Recvfrom failed.\n");
|
||||||
cleanup = 1;
|
cleanup = 1;
|
||||||
}
|
}
|
||||||
pthread_t threadID = pthread_self();
|
|
||||||
pthread_join(threadID, (void*)&connfd);
|
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
|
@ -302,9 +304,10 @@ int main(int argc, char** argv)
|
||||||
printf("Loaded server keys\n");
|
printf("Loaded server keys\n");
|
||||||
|
|
||||||
AwaitDGram();
|
AwaitDGram();
|
||||||
if (cleanup == 1){
|
if (cleanup == 1) {
|
||||||
CyaSSL_Cleanup();
|
CyaSSL_Cleanup();
|
||||||
CyaSSL_CTX_free(ctx);
|
CyaSSL_CTX_free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue