2
0
Эх сурвалжийг харах

Call SSL_shutdown() on clean close only and synchronize it properly

Paul-Louis Ageneau 2 жил өмнө
parent
commit
dba71f8060

+ 4 - 1
src/impl/dtlstransport.cpp

@@ -479,7 +479,6 @@ void DtlsTransport::stop() {
 	unregisterIncoming();
 	mIncomingQueue.stop();
 	mRecvThread.join();
-	SSL_shutdown(mSsl);
 }
 
 bool DtlsTransport::send(message_ptr message) {
@@ -624,6 +623,10 @@ void DtlsTransport::runRecvLoop() {
 
 			mIncomingQueue.wait(duration);
 		}
+
+		std::lock_guard lock(mSslMutex);
+		SSL_shutdown(mSsl);
+
 	} catch (const std::exception &e) {
 		PLOG_ERROR << "DTLS recv: " << e.what();
 	}

+ 3 - 1
src/impl/tlstransport.cpp

@@ -391,7 +391,6 @@ void TlsTransport::stop() {
 	unregisterIncoming();
 	mIncomingQueue.stop();
 	mRecvThread.join();
-	SSL_shutdown(mSsl);
 }
 
 bool TlsTransport::send(message_ptr message) {
@@ -483,6 +482,9 @@ void TlsTransport::runRecvLoop() {
 				recv(message); // Pass zero-sized messages through
 		}
 
+		std::lock_guard lock(mSslMutex);
+		SSL_shutdown(mSsl);
+
 	} catch (const std::exception &e) {
 		PLOG_ERROR << "TLS recv: " << e.what();
 	}