Skip to content

Commit f9de1dd

Browse files
authored
fix state lifetime (#282)
1 parent b016c05 commit f9de1dd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

trantor/net/inner/tlsprovider/OpenSSLProvider.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ struct SSLContext
270270
return ctx_;
271271
}
272272

273-
bool isServer = false;
273+
bool isServer{false};
274274
};
275275

276276
struct OpenSSLCertificate : public Certificate
@@ -697,9 +697,8 @@ struct OpenSSLProvider : public TLSProvider, public NonCopyable
697697
}
698698
else
699699
{
700-
static bool processed = false;
701-
if (!processed)
702-
processed = true;
700+
if (!processedHandshakeError_)
701+
processedHandshakeError_ = true;
703702
else
704703
return false;
705704
LOG_TRACE << "SSL handshake error: "
@@ -776,9 +775,8 @@ struct OpenSSLProvider : public TLSProvider, public NonCopyable
776775
{
777776
sendTLSData();
778777

779-
static bool first = true;
780-
if (first)
781-
first = false;
778+
if (!processedSslError_)
779+
processedSslError_ = true;
782780
else
783781
return;
784782
if (errorCallback_)
@@ -788,6 +786,8 @@ struct OpenSSLProvider : public TLSProvider, public NonCopyable
788786
SSL *ssl_;
789787
BIO *rbio_;
790788
BIO *wbio_;
789+
bool processedHandshakeError_{false};
790+
bool processedSslError_{false};
791791
};
792792

793793
std::unique_ptr<TLSProvider> trantor::newTLSProvider(TcpConnection *conn,
@@ -892,4 +892,4 @@ SSLContextPtr trantor::newSSLContext(const TLSPolicy &policy, bool isServer)
892892
throw std::runtime_error("Failed to select secure ciphers");
893893

894894
return ctx;
895-
}
895+
}

0 commit comments

Comments
 (0)