You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2020/12/16 07:21:09 UTC
[trafficserver] branch master updated: Remove a special treatment
for SSLNetVC in migrateToCurrentThread() (#7384)
This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new dff5156 Remove a special treatment for SSLNetVC in migrateToCurrentThread() (#7384)
dff5156 is described below
commit dff5156b47d89ceec2ea560ccfec4952a7d7aa0e
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Wed Dec 16 16:20:51 2020 +0900
Remove a special treatment for SSLNetVC in migrateToCurrentThread() (#7384)
---
iocore/net/P_SSLNetVConnection.h | 2 ++
iocore/net/P_UnixNetVConnection.h | 4 +++
iocore/net/SSLNetVConnection.cc | 20 +++++++++++++++
iocore/net/SSLUtils.cc | 2 --
iocore/net/UnixNetVConnection.cc | 52 +++++++++++++++++----------------------
5 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/iocore/net/P_SSLNetVConnection.h b/iocore/net/P_SSLNetVConnection.h
index aa415cb..488f495 100644
--- a/iocore/net/P_SSLNetVConnection.h
+++ b/iocore/net/P_SSLNetVConnection.h
@@ -484,6 +484,8 @@ private:
std::string_view map_tls_protocol_to_tag(const char *proto_string) const;
bool update_rbio(bool move_to_socket);
void increment_ssl_version_metric(int version) const;
+ NetProcessor *_getNetProcessor() override;
+ void *_prepareForMigration() override;
enum SSLHandshakeStatus sslHandshakeStatus = SSL_HANDSHAKE_ONGOING;
bool sslClientRenegotiationAbort = false;
diff --git a/iocore/net/P_UnixNetVConnection.h b/iocore/net/P_UnixNetVConnection.h
index 64e1738..29b3366 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -291,6 +291,10 @@ public:
void apply_options() override;
friend void write_to_net_io(NetHandler *, UnixNetVConnection *, EThread *);
+
+private:
+ virtual void *_prepareForMigration();
+ virtual NetProcessor *_getNetProcessor();
};
extern ClassAllocator<UnixNetVConnection> netVCAllocator;
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index a12b2fa..335db49 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -212,6 +212,7 @@ make_ssl_connection(SSL_CTX *ctx, SSLNetVConnection *netvc)
}
SSLNetVCAttach(ssl, netvc);
+ TLSSessionResumptionSupport::bind(ssl, netvc);
}
return ssl;
@@ -1820,6 +1821,7 @@ SSLNetVConnection::populate(Connection &con, Continuation *c, void *arg)
sslHandshakeStatus = SSL_HANDSHAKE_DONE;
SSLNetVCAttach(this->ssl, this);
+ TLSSessionResumptionSupport::bind(this->ssl, this);
return EVENT_DONE;
}
@@ -1937,3 +1939,21 @@ SSLNetVConnection::set_ca_cert_file(std::string_view file, std::string_view dir)
_ca_cert_dir.reset(n);
}
}
+
+void *
+SSLNetVConnection::_prepareForMigration()
+{
+ SSL *save_ssl = this->ssl;
+
+ SSLNetVCDetach(this->ssl);
+ TLSSessionResumptionSupport::unbind(this->ssl);
+ this->ssl = nullptr;
+
+ return save_ssl;
+}
+
+NetProcessor *
+SSLNetVConnection::_getNetProcessor()
+{
+ return &sslNetProcessor;
+}
diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc
index dabf3ad..54a9d35 100644
--- a/iocore/net/SSLUtils.cc
+++ b/iocore/net/SSLUtils.cc
@@ -1705,14 +1705,12 @@ void
SSLNetVCAttach(SSL *ssl, SSLNetVConnection *vc)
{
SSL_set_ex_data(ssl, ssl_vc_index, vc);
- TLSSessionResumptionSupport::bind(ssl, vc);
}
void
SSLNetVCDetach(SSL *ssl)
{
SSL_set_ex_data(ssl, ssl_vc_index, nullptr);
- TLSSessionResumptionSupport::unbind(ssl);
}
SSLNetVConnection *
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 3aac686..ce47d1d 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -1415,14 +1415,8 @@ UnixNetVConnection::migrateToCurrentThread(Continuation *cont, EThread *t)
Connection hold_con;
hold_con.move(this->con);
- SSLNetVConnection *sslvc = dynamic_cast<SSLNetVConnection *>(this);
- SSL *save_ssl = nullptr;
- if (sslvc) {
- save_ssl = sslvc->ssl;
- SSLNetVCDetach(sslvc->ssl);
- sslvc->ssl = nullptr;
- }
+ void *arg = this->_prepareForMigration();
// Do_io_close will signal the VC to be freed on the original thread
// Since we moved the con context, the fd will not be closed
@@ -1431,32 +1425,32 @@ UnixNetVConnection::migrateToCurrentThread(Continuation *cont, EThread *t)
this->ep.stop();
// Create new VC:
- UnixNetVConnection *netvc = nullptr;
- if (save_ssl) {
- sslvc = static_cast<SSLNetVConnection *>(sslNetProcessor.allocate_vc(t));
- if (sslvc->populate(hold_con, cont, save_ssl) != EVENT_DONE) {
- sslvc->do_io_close();
- sslvc = nullptr;
- } else {
- // Update the SSL fields
- sslvc->set_context(get_context());
- }
- netvc = sslvc;
- } else {
- netvc = static_cast<UnixNetVConnection *>(netProcessor.allocate_vc(t));
- if (netvc->populate(hold_con, cont, save_ssl) != EVENT_DONE) {
- netvc->do_io_close();
- netvc = nullptr;
- } else {
- netvc->set_context(get_context());
- }
+ UnixNetVConnection *newvc = static_cast<UnixNetVConnection *>(this->_getNetProcessor()->allocate_vc(t));
+ ink_assert(newvc != nullptr);
+ if (newvc->populate(hold_con, cont, arg) != EVENT_DONE) {
+ newvc->do_io_close();
+ newvc = nullptr;
}
- if (netvc) {
- netvc->options = this->options;
+ if (newvc) {
+ newvc->set_context(get_context());
+ newvc->options = this->options;
}
+
// Do not mark this closed until the end so it does not get freed by the other thread too soon
this->do_io_close();
- return netvc;
+ return newvc;
+}
+
+void *
+UnixNetVConnection::_prepareForMigration()
+{
+ return nullptr;
+}
+
+NetProcessor *
+UnixNetVConnection::_getNetProcessor()
+{
+ return &netProcessor;
}
void