This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 4b7e635b37308447c0893621a6450894f2ed47b4 Author: Susan Hinrichs <[email protected]> AuthorDate: Mon Nov 23 12:23:10 2020 -0600 Fix vc close migration race condition (#7337) (cherry picked from commit 526952faaa21c5d54a0628b20ed3bbc45a03d497) --- iocore/net/UnixNetVConnection.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc index 840469a..0d5ad00 100644 --- a/iocore/net/UnixNetVConnection.cc +++ b/iocore/net/UnixNetVConnection.cc @@ -652,17 +652,11 @@ UnixNetVConnection::do_io_close(int alerrno /* = -1 */) // FIXME: the nh must not nullptr. ink_assert(nh); - // mark it closed first - if (alerrno == -1) { - closed = 1; - } else { - closed = -1; - } + // The vio continuations will be cleared in ::clear called from ::free read.enabled = 0; write.enabled = 0; read.vio.nbytes = 0; read.vio.op = VIO::NONE; - read.vio.cont = nullptr; if (netvc_context == NET_VCONNECTION_OUT) { // do not clear the iobufs yet to guard @@ -676,7 +670,6 @@ UnixNetVConnection::do_io_close(int alerrno /* = -1 */) write.vio.nbytes = 0; write.vio.op = VIO::NONE; - write.vio.cont = nullptr; EThread *t = this_ethread(); bool close_inline = !recursion && (!nh || nh->mutex->thread_holding == t); @@ -686,6 +679,14 @@ UnixNetVConnection::do_io_close(int alerrno /* = -1 */) this->lerrno = alerrno; } + // Must mark for closed last in case this is a + // cross thread migration scenario. + if (alerrno == -1) { + closed = 1; + } else { + closed = -1; + } + if (close_inline) { if (nh) { nh->free_netevent(this);
