This is an automated email from the ASF dual-hosted git repository.

masaori 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 03ff337  Cleanup: Signal READ_READY event only if the buffer is 
readable
03ff337 is described below

commit 03ff3379fbaffb433e632e7d302856699ffeb3a6
Author: Masaori Koshiba <masa...@apache.org>
AuthorDate: Wed Aug 14 10:33:59 2019 +0900

    Cleanup: Signal READ_READY event only if the buffer is readable
    
    READ_READY event is always signaled itself when Http2ClientSession is 
started.
    But this could waste some CPU cycle if there no data to read.
---
 proxy/http2/Http2ClientSession.cc | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/proxy/http2/Http2ClientSession.cc 
b/proxy/http2/Http2ClientSession.cc
index c55cc5c..cc20c57 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -165,19 +165,20 @@ Http2ClientSession::free()
 void
 Http2ClientSession::start()
 {
-  VIO *read_vio;
-
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
 
   SET_HANDLER(&Http2ClientSession::main_event_handler);
   
HTTP2_SET_SESSION_HANDLER(&Http2ClientSession::state_read_connection_preface);
 
-  read_vio  = this->do_io_read(this, INT64_MAX, this->read_buffer);
-  write_vio = this->do_io_write(this, INT64_MAX, this->sm_writer);
+  VIO *read_vio = this->do_io_read(this, INT64_MAX, this->read_buffer);
+  write_vio     = this->do_io_write(this, INT64_MAX, this->sm_writer);
 
   this->connection_state.init();
   send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_INIT, 
this);
-  this->handleEvent(VC_EVENT_READ_READY, read_vio);
+
+  if (this->sm_reader->is_read_avail_more_than(0)) {
+    this->handleEvent(VC_EVENT_READ_READY, read_vio);
+  }
 }
 
 void

Reply via email to