]> WPIA git - cassiopeia.git/blobdiff - src/io/recordHandler.cpp
upd: Reimported logger library by Florian Weber from updated upstream
[cassiopeia.git] / src / io / recordHandler.cpp
index 672712813a579197b7bd736bfdcb4c2169503aec..b55317b1d26b8b6a7f2f89159195c4dbc65e51ab 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <openssl/ssl.h>
 
+#include "util.h"
 #include "io/record.h"
 #include "io/opensslBIO.h"
 #include "io/slipBio.h"
@@ -40,7 +41,7 @@ public:
     RecordHandlerSession( DefaultRecordHandler* parent, std::shared_ptr<Signer> signer, std::shared_ptr<SSL_CTX> ctx, std::shared_ptr<BIO> output ) :
         sessid( 0 ),
         lastCommandCount( 0 ),
-        tbs( new TBSCertificate() ){
+        tbs( new TBSCertificate() ) {
         this->parent = parent;
         this->signer = signer;
         time_t c_time;
@@ -49,12 +50,7 @@ public:
             throw "Error while fetching time?";
         }
 
-        log = std::shared_ptr<std::ofstream>(
-            new std::ofstream( std::string( "logs/log_" ) + std::to_string( c_time ) ),
-            []( std::ofstream * ptr ) {
-                ptr->close();
-                delete ptr;
-            } );
+        log = openLogfile( std::string( "logs/log_" ) + std::to_string( c_time ) );
 
         ssl = std::shared_ptr<SSL>( SSL_new( ctx.get() ), SSL_free );
         std::shared_ptr<BIO> bio(
@@ -185,6 +181,7 @@ public:
             if( !SSL_shutdown( ssl.get() ) && !SSL_shutdown( ssl.get() ) ) {
                 ( *log ) << "ERROR: SSL close failed" << std::endl;
             }
+            parent->reset(); // Connection ended
 
             break;
 
@@ -213,7 +210,7 @@ public:
             if( !SSL_shutdown( ssl.get() ) && !SSL_shutdown( ssl.get() ) ) {
                 ( *log ) << "ERROR: SSL close failed" << std::endl;
             }
-
+            parent->reset(); // Connection ended
             break;
         }