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/29 23:42:59 UTC
[trafficserver] branch 7.1.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 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/7.1.x by this push:
new 8278b40 Added clear_event function to cancel inactive event before marking it as nullptr
8278b40 is described below
commit 8278b40bdf6cf34973edce039655989f190bd041
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 1d467af..9417ab0 100644
--- a/proxy/PluginVC.cc
+++ b/proxy/PluginVC.cc
@@ -211,9 +211,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) {
@@ -751,7 +748,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;
}
@@ -764,7 +761,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);
@@ -775,11 +772,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 024218c..c647b08 100644
--- a/proxy/PluginVC.h
+++ b/proxy/PluginVC.h
@@ -152,6 +152,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();