This is an automated email from the ASF dual-hosted git repository. amc 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 cb78442 Added clear_event function to cancel inactive event before marking it as nullptr cb78442 is described below commit cb784429ec035f4f669bc2d62ad94d26b58c825d Author: dyrock <zeyu...@gmail.com> AuthorDate: Tue Aug 7 18:59:32 2018 +0000 Added clear_event function to cancel inactive event before marking it as nullptr --- proxy/PluginVC.cc | 23 ++++++++++++++++------- proxy/PluginVC.h | 4 ++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc index 55ea62f..3c99653 100644 --- a/proxy/PluginVC.cc +++ b/proxy/PluginVC.cc @@ -208,9 +208,6 @@ PluginVC::main_handler(int event, void *data) } else if (call_event == inactive_event) { if (inactive_timeout_at && inactive_timeout_at < Thread::get_hrtime()) { process_timeout(&inactive_event, VC_EVENT_INACTIVITY_TIMEOUT); - if (nullptr == inactive_event) { - call_event->cancel(); - } } } else { if (call_event == sm_lock_retry_event) { @@ -748,7 +745,7 @@ PluginVC::process_timeout(Event **e, int event_to_send) if (closed) { // already closed, ignore the timeout event // to avoid handle_event asserting use-after-free - *e = nullptr; + clear_event(e); return; } @@ -761,7 +758,7 @@ PluginVC::process_timeout(Event **e, int event_to_send) } return; } - *e = nullptr; + clear_event(e); read_state.vio.cont->handleEvent(event_to_send, &read_state.vio); } else if (write_state.vio.op == VIO::WRITE && !write_state.shutdown && write_state.vio.ntodo() > 0) { MUTEX_TRY_LOCK(lock, write_state.vio.mutex, (*e)->ethread); @@ -772,11 +769,23 @@ PluginVC::process_timeout(Event **e, int event_to_send) } return; } - *e = nullptr; + clear_event(e); write_state.vio.cont->handleEvent(event_to_send, &write_state.vio); } else { - *e = nullptr; + clear_event(e); + } +} + +void +PluginVC::clear_event(Event **e) +{ + if (e == nullptr || *e == nullptr) + return; + if (*e == inactive_event) { + inactive_event->cancel(); + inactive_timeout_at = 0; } + *e = nullptr; } void diff --git a/proxy/PluginVC.h b/proxy/PluginVC.h index 96aba0f..7ce9a85 100644 --- a/proxy/PluginVC.h +++ b/proxy/PluginVC.h @@ -151,6 +151,10 @@ private: void process_close(); void process_timeout(Event **e, int event_to_send); + // Clear the Event pointer pointed to by e + // Cancel the action first if it is a periodic event + void clear_event(Event **e); + void setup_event_cb(ink_hrtime in, Event **e_ptr); void update_inactive_time();