You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/04/10 06:41:46 UTC
[trafficserver] branch quic-latest updated: Send cross thread event
to the right thread on HQTransaction
This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/quic-latest by this push:
new 084ad24 Send cross thread event to the right thread on HQTransaction
084ad24 is described below
commit 084ad245364f9137e667ad7baf6a2d3116204397
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Tue Apr 10 15:31:25 2018 +0900
Send cross thread event to the right thread on HQTransaction
---
proxy/hq/HQClientTransaction.cc | 37 ++++++++++++++++++++++++++++++++++++-
proxy/hq/HQClientTransaction.h | 3 +++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/proxy/hq/HQClientTransaction.cc b/proxy/hq/HQClientTransaction.cc
index c60cef6..3574b65 100644
--- a/proxy/hq/HQClientTransaction.cc
+++ b/proxy/hq/HQClientTransaction.cc
@@ -50,7 +50,9 @@
HQClientTransaction::HQClientTransaction(HQClientSession *session, QUICStreamIO *stream_io) : super(), _stream_io(stream_io)
{
- this->mutex = new_ProxyMutex();
+ this->mutex = new_ProxyMutex();
+ this->_thread = this_ethread();
+
this->set_parent(session);
this->sm_reader = this->_read_vio_buf.alloc_reader();
static_cast<HQClientSession *>(this->parent)->add_transaction(this);
@@ -120,6 +122,21 @@ HQClientTransaction::state_stream_open(int event, void *edata)
// TODO: should check recursive call?
HQTransDebug("%s (%d)", get_vc_event_name(event), event);
+ if (this->_thread != this_ethread()) {
+ // Send on to the owning thread
+ if (this->_cross_thread_event == nullptr) {
+ this->_cross_thread_event = this->_thread->schedule_imm(this, event, edata);
+ }
+ return 0;
+ }
+
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+
+ Event *e = static_cast<Event *>(edata);
+ if (e == this->_cross_thread_event) {
+ this->_cross_thread_event = nullptr;
+ }
+
switch (event) {
case VC_EVENT_READ_READY:
case VC_EVENT_READ_COMPLETE: {
@@ -374,6 +391,15 @@ HQClientTransaction::_process_read_vio()
return 0;
}
+ if (this->_thread != this_ethread()) {
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+ if (this->_cross_thread_event == nullptr) {
+ // Send to the right thread
+ this->_cross_thread_event = this->_thread->schedule_imm(this, VC_EVENT_READ_READY, nullptr);
+ }
+ return 0;
+ }
+
SCOPED_MUTEX_LOCK(lock, this->_read_vio.mutex, this_ethread());
IOBufferReader *client_vio_reader = this->_stream_io->get_read_buffer_reader();
@@ -444,6 +470,15 @@ HQClientTransaction::_process_write_vio()
return 0;
}
+ if (this->_thread != this_ethread()) {
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+ if (this->_cross_thread_event == nullptr) {
+ // Send to the right thread
+ this->_cross_thread_event = this->_thread->schedule_imm(this, VC_EVENT_WRITE_READY, nullptr);
+ }
+ return 0;
+ }
+
SCOPED_MUTEX_LOCK(lock, this->_write_vio.mutex, this_ethread());
IOBufferReader *reader = this->_write_vio.get_reader();
diff --git a/proxy/hq/HQClientTransaction.h b/proxy/hq/HQClientTransaction.h
index 155cbc5..d24c3bf 100644
--- a/proxy/hq/HQClientTransaction.h
+++ b/proxy/hq/HQClientTransaction.h
@@ -74,6 +74,9 @@ private:
int64_t _process_read_vio();
int64_t _process_write_vio();
+ EThread *_thread = nullptr;
+ Event *_cross_thread_event = nullptr;
+
MIOBuffer _read_vio_buf = CLIENT_CONNECTION_FIRST_READ_BUFFER_SIZE_INDEX;
QUICStreamIO *_stream_io = nullptr;
--
To stop receiving notification emails like this one, please contact
masaori@apache.org.