You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2018/08/13 18:44:47 UTC
[trafficserver] branch 8.0.x updated: Added clear_event function to
cancel inactive event before marking it as nullptr
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/8.0.x by this push:
new 7d33ac8 Added clear_event function to cancel inactive event before marking it as nullptr
7d33ac8 is described below
commit 7d33ac8cb89bbcb074e0910290bb8d1301e4196e
Author: dyrock <ze...@gmail.com>
AuthorDate: Tue Aug 7 18:59:32 2018 +0000
Added clear_event function to cancel inactive event before marking it as nullptr
(cherry picked from commit cb784429ec035f4f669bc2d62ad94d26b58c825d)
---
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();