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 47078f9  Acquire a lock before _frame_send_queue operation
47078f9 is described below

commit 47078f9aa1c62e9b7e80fb2fe2d95aeb5b1fa139
Author: Masaori Koshiba <masa...@apache.org>
AuthorDate: Fri Sep 15 11:25:11 2017 +0900

    Acquire a lock before _frame_send_queue operation
---
 iocore/net/P_QUICNetVConnection.h       |  5 +++--
 iocore/net/QUICNetVConnection.cc        | 20 +++++++++++++-------
 iocore/net/quic/QUICLossDetector.cc     |  2 +-
 iocore/net/quic/QUICPacketTransmitter.h |  2 +-
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h 
b/iocore/net/P_QUICNetVConnection.h
index 01b689c..b29d2d6 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -181,7 +181,7 @@ public:
   // QUICConnection (QUICPacketTransmitter)
   virtual void transmit_packet(std::unique_ptr<QUICPacket, 
QUICPacketDeleterFunc> packet) override;
   virtual void retransmit_packet(const QUICPacket &packet) override;
-  virtual Ptr<ProxyMutex> get_transmitter_mutex() override;
+  virtual Ptr<ProxyMutex> get_packet_transmitter_mutex() override;
 
   // QUICConnection (QUICFrameTransmitter)
   virtual void transmit_frame(std::unique_ptr<QUICFrame, QUICFrameDeleterFunc> 
frame) override;
@@ -236,7 +236,8 @@ private:
   QUICError _state_common_receive_packet();
   QUICError _state_common_send_packet();
 
-  Ptr<ProxyMutex> _transmitter_mutex;
+  Ptr<ProxyMutex> _packet_transmitter_mutex;
+  Ptr<ProxyMutex> _frame_transmitter_mutex;
 
   QUICApplication *_create_application();
   void _init_flow_control_params(const std::shared_ptr<const 
QUICTransportParameters> &local_tp,
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 8f25ca9..aefd28c 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -61,9 +61,10 @@ QUICNetVConnection::QUICNetVConnection() : 
UnixNetVConnection()
 void
 QUICNetVConnection::init(UDPConnection *udp_con, QUICPacketHandler 
*packet_handler)
 {
-  this->_transmitter_mutex = new_ProxyMutex();
-  this->_udp_con           = udp_con;
-  this->_packet_handler    = packet_handler;
+  this->_packet_transmitter_mutex = new_ProxyMutex();
+  this->_frame_transmitter_mutex  = new_ProxyMutex();
+  this->_udp_con                  = udp_con;
+  this->_packet_handler           = packet_handler;
   this->_quic_connection_id.randomize();
 
   // FIXME These should be done by HttpProxyServerMain
@@ -231,9 +232,9 @@ QUICNetVConnection::retransmit_packet(const QUICPacket 
&packet)
 }
 
 Ptr<ProxyMutex>
-QUICNetVConnection::get_transmitter_mutex()
+QUICNetVConnection::get_packet_transmitter_mutex()
 {
-  return this->_transmitter_mutex;
+  return this->_packet_transmitter_mutex;
 }
 
 void
@@ -248,6 +249,8 @@ void
 QUICNetVConnection::transmit_frame(std::unique_ptr<QUICFrame, 
QUICFrameDeleterFunc> frame)
 {
   DebugQUICCon("Type=%s Size=%zu", QUICDebugNames::frame_type(frame->type()), 
frame->size());
+
+  SCOPED_MUTEX_LOCK(frame_transmitter_lock, this->_frame_transmitter_mutex, 
this_ethread());
   this->_frame_send_queue.push(std::move(frame));
   if (!this->_packet_write_ready) {
     this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, 
QUIC_EVENT_PACKET_WRITE_READY, nullptr);
@@ -641,6 +644,8 @@ QUICNetVConnection::_state_common_send_packet()
   if (error.cls != QUICErrorClass::NONE) {
     return error;
   }
+
+  SCOPED_MUTEX_LOCK(packet_transmitter_lock, 
this->get_packet_transmitter_mutex().get(), this_ethread());
   while ((packet = this->_packet_send_queue.dequeue()) != nullptr) {
     this->_packet_handler->send_packet(*packet, this);
     this->_loss_detector->on_packet_sent(
@@ -666,6 +671,7 @@ QUICNetVConnection::_packetize_frames()
   QUICPacketType previous_packet_type = QUICPacketType::UNINITIALIZED;
   QUICPacketType current_packet_type  = QUICPacketType::UNINITIALIZED;
 
+  SCOPED_MUTEX_LOCK(frame_transmitter_lock, this->_frame_transmitter_mutex, 
this_ethread());
   while (this->_frame_send_queue.size() > 0) {
     frame = std::move(this->_frame_send_queue.front());
     this->_frame_send_queue.pop();
@@ -678,7 +684,7 @@ QUICNetVConnection::_packetize_frames()
     }
     if (len + frame->size() + MAX_PACKET_OVERHEAD > max_size || 
(previous_packet_type != current_packet_type && len > 0)) {
       ink_assert(len > 0);
-      SCOPED_MUTEX_LOCK(transmitter_lock, this->get_transmitter_mutex().get(), 
this_ethread());
+      SCOPED_MUTEX_LOCK(packet_transmitter_lock, 
this->get_packet_transmitter_mutex().get(), this_ethread());
       this->transmit_packet(this->_build_packet(std::move(buf), len, 
retransmittable, previous_packet_type));
       len = 0;
     }
@@ -700,7 +706,7 @@ QUICNetVConnection::_packetize_frames()
       memset(buf.get() + len, 0, min_size - len);
       len += min_size - len;
     }
-    SCOPED_MUTEX_LOCK(transmitter_lock, this->get_transmitter_mutex().get(), 
this_ethread());
+    SCOPED_MUTEX_LOCK(packet_transmitter_lock, 
this->get_packet_transmitter_mutex().get(), this_ethread());
     this->transmit_packet(this->_build_packet(std::move(buf), len, 
retransmittable, current_packet_type));
   }
 }
diff --git a/iocore/net/quic/QUICLossDetector.cc 
b/iocore/net/quic/QUICLossDetector.cc
index fb72bc2..46ded5a 100644
--- a/iocore/net/quic/QUICLossDetector.cc
+++ b/iocore/net/quic/QUICLossDetector.cc
@@ -344,7 +344,7 @@ QUICLossDetector::_determine_newly_acked_packets(const 
QUICAckFrame &ack_frame)
 void
 QUICLossDetector::_retransmit_handshake_packets()
 {
-  SCOPED_MUTEX_LOCK(transmitter_lock, 
this->_transmitter->get_transmitter_mutex().get(), this_ethread());
+  SCOPED_MUTEX_LOCK(transmitter_lock, 
this->_transmitter->get_packet_transmitter_mutex().get(), this_ethread());
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
   std::set<QUICPacketNumber> retransmitted_handshake_packets;
 
diff --git a/iocore/net/quic/QUICPacketTransmitter.h 
b/iocore/net/quic/QUICPacketTransmitter.h
index 67c8fa5..6aaef38 100644
--- a/iocore/net/quic/QUICPacketTransmitter.h
+++ b/iocore/net/quic/QUICPacketTransmitter.h
@@ -46,5 +46,5 @@ public:
    * Returns a mutex for transmitter interfaces.
    * You have to acquire a lock with this mutex before calling any methods 
provieded by QUICPacketTransmitter
    */
-  virtual Ptr<ProxyMutex> get_transmitter_mutex() = 0;
+  virtual Ptr<ProxyMutex> get_packet_transmitter_mutex() = 0;
 };

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Reply via email to