From 751b24abc525cae8956587991bd0fa19f53b69eb Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Fri, 13 Sep 2019 09:16:33 +0900 Subject: [PATCH] Track scheduled events to (read|write)_vio.cont from Http2Stream --- proxy/http2/Http2Stream.cc | 30 ++++++++++++++++++++++++++---- proxy/http2/Http2Stream.h | 6 ++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc index 0f80ad00fe2..e4d6542cb0b 100644 --- a/proxy/http2/Http2Stream.cc +++ b/proxy/http2/Http2Stream.cc @@ -99,14 +99,20 @@ Http2Stream::main_event_handler(int event, void *edata) if (lock.is_locked()) { read_vio.cont->handleEvent(event, &read_vio); } else { - this_ethread()->schedule_imm(read_vio.cont, event, &read_vio); + if (this->_read_vio_event) { + this->_read_vio_event->cancel(); + } + this->_read_vio_event = this_ethread()->schedule_imm(read_vio.cont, event, &read_vio); } } else if (_sm && write_vio.ntodo() > 0) { MUTEX_TRY_LOCK(lock, write_vio.mutex, this_ethread()); if (lock.is_locked()) { write_vio.cont->handleEvent(event, &write_vio); } else { - this_ethread()->schedule_imm(write_vio.cont, event, &write_vio); + if (this->_write_vio_event) { + this->_write_vio_event->cancel(); + } + this->_write_vio_event = this_ethread()->schedule_imm(write_vio.cont, event, &write_vio); } } break; @@ -119,7 +125,10 @@ Http2Stream::main_event_handler(int event, void *edata) if (lock.is_locked()) { write_vio.cont->handleEvent(event, &write_vio); } else { - this_ethread()->schedule_imm(write_vio.cont, event, &write_vio); + if (this->_write_vio_event) { + this->_write_vio_event->cancel(); + } + this->_write_vio_event = this_ethread()->schedule_imm(write_vio.cont, event, &write_vio); } } } else { @@ -135,7 +144,10 @@ Http2Stream::main_event_handler(int event, void *edata) if (lock.is_locked()) { read_vio.cont->handleEvent(event, &read_vio); } else { - this_ethread()->schedule_imm(read_vio.cont, event, &read_vio); + if (this->_read_vio_event) { + this->_read_vio_event->cancel(); + } + this->_read_vio_event = this_ethread()->schedule_imm(read_vio.cont, event, &read_vio); } } } else { @@ -937,6 +949,16 @@ Http2Stream::clear_io_events() buffer_full_write_event->cancel(); buffer_full_write_event = nullptr; } + + if (this->_read_vio_event) { + this->_read_vio_event->cancel(); + this->_read_vio_event = nullptr; + } + + if (this->_write_vio_event) { + this->_write_vio_event->cancel(); + this->_write_vio_event = nullptr; + } } void diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h index 471e4046b06..8b0489b0c7d 100644 --- a/proxy/http2/Http2Stream.h +++ b/proxy/http2/Http2Stream.h @@ -218,8 +218,10 @@ class Http2Stream : public ProxyTransaction ink_hrtime inactive_timeout_at = 0; Event *inactive_event = nullptr; - Event *read_event = nullptr; - Event *write_event = nullptr; + Event *read_event = nullptr; + Event *write_event = nullptr; + Event *_read_vio_event = nullptr; + Event *_write_vio_event = nullptr; }; extern ClassAllocator http2StreamAllocator;