]> Nishi Git Mirror - tewi.git/commitdiff
close socket properly
authorNishi <nishi@nishi.boats>
Fri, 13 Sep 2024 13:49:53 +0000 (13:49 +0000)
committerNishi <nishi@nishi.boats>
Fri, 13 Sep 2024 13:49:53 +0000 (13:49 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@15 8739d7e6-ffea-ec47-b151-bdff447c6205

Server/server.c

index 0690d27faa2021b09e5b5bc96cdfc9f50b75a125..120e5a1b26763e4167a1ddb172346127d9b785b8 100644 (file)
@@ -131,13 +131,19 @@ void tw_server_pass(int sock, bool ssl, int port) {
 
        SSL_CTX* ctx = NULL;
        SSL* s = NULL;
+       bool sslworks = false;
        if(ssl) {
                ctx = tw_create_ssl_ctx(port);
                s = SSL_new(ctx);
                SSL_set_fd(s, sock);
                if(SSL_accept(s) <= 0) goto cleanup;
+               sslworks = true;
        }
 cleanup:
+       if(sslworks){
+               SSL_shutdown(s);
+       }
+       SSL_free(s);
        close_socket(sock);
 #ifdef __MINGW32__
        _endthreadex(0);