diff --git a/iocore/net/P_SSLNetVConnection.h b/iocore/net/P_SSLNetVConnection.h index 1691c0e5e7e..9e1f6ab0c56 100644 --- a/iocore/net/P_SSLNetVConnection.h +++ b/iocore/net/P_SSLNetVConnection.h @@ -134,7 +134,6 @@ class SSLNetVConnection : public UnixNetVConnection, int sslClientHandShakeEvent(int &err); void net_read_io(NetHandler *nh, EThread *lthread) override; int64_t load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf, int64_t &total_written, int &needs) override; - void do_io_close(int lerrno = -1) override; //////////////////////////////////////////////////////////// // Instances of NetVConnection should be allocated // @@ -435,6 +434,8 @@ class SSLNetVConnection : public UnixNetVConnection, } protected: + void _do_io_close(int lerrno) override; + SSL * _get_ssl_object() const override { diff --git a/iocore/net/P_UnixNetVConnection.h b/iocore/net/P_UnixNetVConnection.h index 65e763f9897..908e50fa6e9 100644 --- a/iocore/net/P_UnixNetVConnection.h +++ b/iocore/net/P_UnixNetVConnection.h @@ -271,7 +271,12 @@ class UnixNetVConnection : public NetVConnection, public NetEvent friend void write_to_net_io(NetHandler *, UnixNetVConnection *, EThread *); +protected: + virtual void _do_io_close(int lerrno); + private: + bool _need_do_io_close = false; + virtual void *_prepareForMigration(); virtual NetProcessor *_getNetProcessor(); }; @@ -357,7 +362,10 @@ UnixNetVConnection::cancel_active_timeout() next_activity_timeout_at = 0; } -inline UnixNetVConnection::~UnixNetVConnection() {} +inline UnixNetVConnection::~UnixNetVConnection() +{ + ink_assert(!this->_need_do_io_close); +} inline SOCKET UnixNetVConnection::get_socket() diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc index 74e4e10f37b..82966184f31 100644 --- a/iocore/net/SSLNetVConnection.cc +++ b/iocore/net/SSLNetVConnection.cc @@ -891,7 +891,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf SSLNetVConnection::SSLNetVConnection() {} void -SSLNetVConnection::do_io_close(int lerrno) +SSLNetVConnection::_do_io_close(int lerrno) { if (this->ssl != nullptr) { if (get_context() == NET_VCONNECTION_OUT) { @@ -937,7 +937,7 @@ SSLNetVConnection::do_io_close(int lerrno) } } // Go on and do the unix socket cleanups - super::do_io_close(lerrno); + super::_do_io_close(lerrno); } void diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc index 0bb3ecf5816..5dbe75f6e79 100644 --- a/iocore/net/UnixNetVConnection.cc +++ b/iocore/net/UnixNetVConnection.cc @@ -590,6 +590,11 @@ UnixNetVConnection::do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf) Error("do_io_read invoked on closed vc %p, cont %p, nbytes %" PRId64 ", buf %p", this, c, nbytes, buf); return nullptr; } + + if (buf) { + this->_need_do_io_close = true; + } + read.vio.op = VIO::READ; read.vio.mutex = c ? c->mutex : this->mutex; read.vio.cont = c; @@ -615,6 +620,11 @@ UnixNetVConnection::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader Error("do_io_write invoked on closed vc %p, cont %p, nbytes %" PRId64 ", reader %p", this, c, nbytes, reader); return nullptr; } + + if (reader) { + this->_need_do_io_close = true; + } + write.vio.op = VIO::WRITE; write.vio.mutex = c ? c->mutex : this->mutex; write.vio.cont = c; @@ -635,6 +645,13 @@ UnixNetVConnection::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader void UnixNetVConnection::do_io_close(int alerrno /* = -1 */) +{ + this->_need_do_io_close = false; + this->_do_io_close(alerrno); +} + +void +UnixNetVConnection::_do_io_close(int alerrno) { // FIXME: the nh must not nullptr. ink_assert(nh);