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 2017/10/05 12:43:36 UTC

[trafficserver] branch quic-latest updated: Add connection id to debug logs from QUICStream

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

maskit 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 6e223b7  Add connection id to debug logs from QUICStream
6e223b7 is described below

commit 6e223b7fe1e19f5df7d75152f89a571e29e355c2
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Thu Oct 5 05:42:51 2017 -0700

    Add connection id to debug logs from QUICStream
---
 iocore/net/QUICNetVConnection.cc               |  2 +-
 iocore/net/quic/QUICStream.cc                  | 44 +++++++++++++-------------
 iocore/net/quic/QUICStream.h                   | 12 ++++---
 iocore/net/quic/QUICStreamManager.cc           |  9 +++---
 iocore/net/quic/QUICStreamManager.h            |  3 +-
 iocore/net/quic/test/test_QUICFrame.cc         |  2 +-
 iocore/net/quic/test/test_QUICStream.cc        |  6 ++--
 iocore/net/quic/test/test_QUICStreamManager.cc |  8 ++---
 8 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index cd2e832..9819b51 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -107,7 +107,7 @@ QUICNetVConnection::start(SSL_CTX *ssl_ctx)
   this->_packet_factory.set_crypto_module(this->_crypto);
 
   // Create frame handlers
-  this->_stream_manager         = new QUICStreamManager(this, this->_application_map);
+  this->_stream_manager         = new QUICStreamManager(this->connection_id(), this, this->_application_map);
   this->_congestion_controller  = new QUICCongestionController();
   this->_loss_detector          = new QUICLossDetector(this);
   this->_remote_flow_controller = new QUICRemoteConnectionFlowController(0, this);
diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc
index a6fd600..7a7bbdc 100644
--- a/iocore/net/quic/QUICStream.cc
+++ b/iocore/net/quic/QUICStream.cc
@@ -28,15 +28,21 @@
 #include "QUICDebugNames.h"
 #include "QUICConfig.h"
 
-#define DebugQUICStream(fmt, ...) \
-  Debug("quic_stream", "[%" PRIx32 "] [%s] " fmt, this->_id, QUICDebugNames::stream_state(this->_state), ##__VA_ARGS__)
+#define DebugQUICStream(fmt, ...)                                                                                       \
+  Debug("quic_stream", "[%" PRIx64 "] [%" PRIx32 "] [%s] " fmt, static_cast<uint64_t>(this->_connection_id), this->_id, \
+        QUICDebugNames::stream_state(this->_state), ##__VA_ARGS__)
+#define DebugQUICStreamFC(fmt, ...)                                                                                        \
+  Debug("quic_flow_ctrl", "[%" PRIx64 "] [%" PRIx32 "] [%s] " fmt, static_cast<uint64_t>(this->_connection_id), this->_id, \
+        QUICDebugNames::stream_state(this->_state), ##__VA_ARGS__)
 
 void
-QUICStream::init(QUICFrameTransmitter *tx, QUICStreamId id, uint64_t recv_max_stream_data, uint64_t send_max_stream_data)
+QUICStream::init(QUICFrameTransmitter *tx, QUICConnectionId cid, QUICStreamId sid, uint64_t recv_max_stream_data,
+                 uint64_t send_max_stream_data)
 {
   this->mutex                   = new_ProxyMutex();
   this->_tx                     = tx;
-  this->_id                     = id;
+  this->_connection_id          = cid;
+  this->_id                     = sid;
   this->_remote_flow_controller = new QUICRemoteStreamFlowController(send_max_stream_data, _tx, _id);
   this->_local_flow_controller  = new QUICLocalStreamFlowController(recv_max_stream_data, _tx, _id);
   this->init_flow_control_params(recv_max_stream_data, send_max_stream_data);
@@ -56,12 +62,10 @@ QUICStream::init_flow_control_params(uint32_t recv_max_stream_data, uint32_t sen
   this->_flow_control_buffer_size = recv_max_stream_data;
   this->_local_flow_controller->forward_limit(recv_max_stream_data);
   this->_remote_flow_controller->forward_limit(send_max_stream_data);
-  Debug("quic_flow_ctrl", "Stream [%" PRIx32 "] [%s] [LOCAL] %" PRIu64 "/%" PRIu64, this->_id,
-        QUICDebugNames::stream_state(this->_state), this->_local_flow_controller->current_offset(),
-        this->_local_flow_controller->current_limit());
-  Debug("quic_flow_ctrl", "Stream [%" PRIx32 "] [%s] [REMOTE] %" PRIu64 "/%" PRIu64, this->_id,
-        QUICDebugNames::stream_state(this->_state), this->_remote_flow_controller->current_offset(),
-        this->_remote_flow_controller->current_limit());
+  DebugQUICStreamFC("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
+                    this->_local_flow_controller->current_limit());
+  DebugQUICStreamFC("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller->current_offset(),
+                    this->_remote_flow_controller->current_limit());
 }
 
 QUICStreamId
@@ -271,9 +275,8 @@ QUICStream::_write_to_read_vio(const std::shared_ptr<const QUICStreamFrame> &fra
   this->_read_vio.nbytes += bytes_added;
   this->_recv_offset += frame->data_length();
   this->_local_flow_controller->forward_limit(this->_recv_offset + this->_flow_control_buffer_size);
-  Debug("quic_flow_ctrl", "Stream [%" PRIx32 "] [%s] [LOCAL] %" PRIu64 "/%" PRIu64, this->_id,
-        QUICDebugNames::stream_state(this->_state), this->_local_flow_controller->current_offset(),
-        this->_local_flow_controller->current_limit());
+  DebugQUICStreamFC("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
+                    this->_local_flow_controller->current_limit());
 
   this->_state.update_with_received_frame(*frame);
 }
@@ -308,9 +311,8 @@ QUICStream::recv(const std::shared_ptr<const QUICStreamFrame> frame)
 
   // Flow Control - Even if it's allowed to receive on the state, it may exceed the limit
   QUICErrorUPtr error = this->_local_flow_controller->update(frame->offset() + frame->data_length());
-  Debug("quic_flow_ctrl", "Stream [%" PRIx32 "] [%s] [LOCAL] %" PRIu64 "/%" PRIu64, this->_id,
-        QUICDebugNames::stream_state(this->_state), this->_local_flow_controller->current_offset(),
-        this->_local_flow_controller->current_limit());
+  DebugQUICStreamFC("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
+                    this->_local_flow_controller->current_limit());
   if (error->cls != QUICErrorClass::NONE) {
     return error;
   }
@@ -335,9 +337,8 @@ QUICErrorUPtr
 QUICStream::recv(const std::shared_ptr<const QUICMaxStreamDataFrame> frame)
 {
   this->_remote_flow_controller->forward_limit(frame->maximum_stream_data());
-  Debug("quic_flow_ctrl", "Stream [%" PRIx32 "] [%s] [REMOTE] %" PRIu64 "/%" PRIu64, this->_id,
-        QUICDebugNames::stream_state(this->_state), this->_remote_flow_controller->current_offset(),
-        this->_remote_flow_controller->current_limit());
+  DebugQUICStreamFC("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller->current_offset(),
+                    this->_remote_flow_controller->current_limit());
 
   this->reenable(&this->_write_vio);
 
@@ -381,9 +382,8 @@ QUICStream::_send()
     }
 
     error = this->_remote_flow_controller->update(this->_send_offset + len);
-    Debug("quic_flow_ctrl", "Stream [%" PRIx32 "] [%s] [REMOTE] %" PRIu64 "/%" PRIu64, this->_id,
-          QUICDebugNames::stream_state(this->_state), this->_remote_flow_controller->current_offset(),
-          this->_remote_flow_controller->current_limit());
+    DebugQUICStreamFC("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller->current_offset(),
+                      this->_remote_flow_controller->current_limit());
     if (error->cls != QUICErrorClass::NONE) {
       break;
     }
diff --git a/iocore/net/quic/QUICStream.h b/iocore/net/quic/QUICStream.h
index a916ead..b1d0765 100644
--- a/iocore/net/quic/QUICStream.h
+++ b/iocore/net/quic/QUICStream.h
@@ -46,7 +46,8 @@ class QUICStream : public VConnection
 public:
   QUICStream() : VConnection(nullptr) {}
   ~QUICStream() {}
-  void init(QUICFrameTransmitter *tx, uint32_t id, uint64_t recv_max_stream_data = 0, uint64_t send_max_stream_data = 0);
+  void init(QUICFrameTransmitter *tx, QUICConnectionId cid, QUICStreamId id, uint64_t recv_max_stream_data = 0,
+            uint64_t send_max_stream_data = 0);
   void start();
   void init_flow_control_params(uint32_t recv_max_stream_data, uint32_t send_max_stream_data);
   int main_event_handler(int event, void *data);
@@ -91,10 +92,11 @@ private:
 
   Event *_send_tracked_event(Event *event, int send_event, VIO *vio);
 
-  bool _fin               = false;
-  QUICStreamId _id        = 0;
-  QUICOffset _recv_offset = 0;
-  QUICOffset _send_offset = 0;
+  bool _fin                       = false;
+  QUICConnectionId _connection_id = 0;
+  QUICStreamId _id                = 0;
+  QUICOffset _recv_offset         = 0;
+  QUICOffset _send_offset         = 0;
 
   QUICRemoteStreamFlowController *_remote_flow_controller = nullptr;
   QUICLocalStreamFlowController *_local_flow_controller   = nullptr;
diff --git a/iocore/net/quic/QUICStreamManager.cc b/iocore/net/quic/QUICStreamManager.cc
index 2832328..47b4bbe 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -25,14 +25,14 @@
 
 #include "QUICApplication.h"
 #include "QUICTransportParameters.h"
-#include "QUICConnection.h"
 
 static constexpr char tag[] = "quic_stream_manager";
 
 ClassAllocator<QUICStreamManager> quicStreamManagerAllocator("quicStreamManagerAllocator");
 ClassAllocator<QUICStream> quicStreamAllocator("quicStreamAllocator");
 
-QUICStreamManager::QUICStreamManager(QUICFrameTransmitter *tx, QUICApplicationMap *app_map) : _tx(tx), _app_map(app_map)
+QUICStreamManager::QUICStreamManager(QUICConnectionId cid, QUICFrameTransmitter *tx, QUICApplicationMap *app_map)
+  : _connection_id(cid), _tx(tx), _app_map(app_map)
 {
 }
 
@@ -205,13 +205,14 @@ QUICStreamManager::_find_or_create_stream(QUICStreamId stream_id)
     stream = new (THREAD_ALLOC(quicStreamAllocator, this_ethread())) QUICStream();
     if (stream_id == STREAM_ID_FOR_HANDSHAKE) {
       // XXX rece/send max_stream_data are going to be set by init_flow_control_params()
-      stream->init(this->_tx, stream_id, this->_local_tp->initial_max_stream_data());
+      stream->init(this->_tx, this->_connection_id, stream_id, this->_local_tp->initial_max_stream_data());
     } else {
       const QUICTransportParameters &local_tp  = *this->_local_tp;
       const QUICTransportParameters &remote_tp = *this->_remote_tp;
 
       // TODO: check local_tp and remote_tp is initialized
-      stream->init(this->_tx, stream_id, local_tp.initial_max_stream_data(), remote_tp.initial_max_stream_data());
+      stream->init(this->_tx, this->_connection_id, stream_id, local_tp.initial_max_stream_data(),
+                   remote_tp.initial_max_stream_data());
     }
 
     stream->start();
diff --git a/iocore/net/quic/QUICStreamManager.h b/iocore/net/quic/QUICStreamManager.h
index b6ad75f..e067cc1 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -36,7 +36,7 @@ class QUICStreamManager : public QUICFrameHandler
 {
 public:
   QUICStreamManager(){};
-  QUICStreamManager(QUICFrameTransmitter *tx, QUICApplicationMap *app_map);
+  QUICStreamManager(QUICConnectionId cid, QUICFrameTransmitter *tx, QUICApplicationMap *app_map);
 
   void init_flow_control_params(const std::shared_ptr<const QUICTransportParameters> &local_tp,
                                 const std::shared_ptr<const QUICTransportParameters> &remote_tp);
@@ -64,6 +64,7 @@ private:
   QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICStreamBlockedFrame> &);
   QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICMaxStreamIdFrame> &);
 
+  QUICConnectionId _connection_id                           = 0;
   QUICFrameTransmitter *_tx                                 = nullptr;
   QUICApplicationMap *_app_map                              = nullptr;
   std::shared_ptr<const QUICTransportParameters> _local_tp  = nullptr;
diff --git a/iocore/net/quic/test/test_QUICFrame.cc b/iocore/net/quic/test/test_QUICFrame.cc
index be140b3..90c82fb 100644
--- a/iocore/net/quic/test/test_QUICFrame.cc
+++ b/iocore/net/quic/test/test_QUICFrame.cc
@@ -731,7 +731,7 @@ TEST_CASE("QUICFrameFactory Create CONNECTION_CLOSE with a QUICConnectionError",
 TEST_CASE("QUICFrameFactory Create RST_STREAM with a QUICStreamError", "[quic]")
 {
   QUICStream stream;
-  stream.init(new MockQUICFrameTransmitter(), 0x1234, 0, 0);
+  stream.init(new MockQUICFrameTransmitter(), 0, 0x1234, 0, 0);
   std::unique_ptr<QUICStreamError> error =
     std::unique_ptr<QUICStreamError>(new QUICStreamError(&stream, QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::INTERNAL_ERROR));
   std::unique_ptr<QUICRstStreamFrame, QUICFrameDeleterFunc> rst_stream_frame1 =
diff --git a/iocore/net/quic/test/test_QUICStream.cc b/iocore/net/quic/test/test_QUICStream.cc
index 545d353..632ad91 100644
--- a/iocore/net/quic/test/test_QUICStream.cc
+++ b/iocore/net/quic/test/test_QUICStream.cc
@@ -48,7 +48,7 @@ TEST_CASE("QUICStream_assembling_byte_stream_1", "[quic]")
   MockQUICFrameTransmitter tx;
 
   std::unique_ptr<QUICStream> stream(new QUICStream());
-  stream->init(&tx, stream_id, 1024, 1024);
+  stream->init(&tx, 0, stream_id, 1024, 1024);
   stream->do_io_read(nullptr, 0, read_buffer);
 
   stream->recv(frame_1);
@@ -75,7 +75,7 @@ TEST_CASE("QUICStream_assembling_byte_stream_2", "[quic]")
   MockQUICFrameTransmitter tx;
 
   std::unique_ptr<QUICStream> stream(new QUICStream());
-  stream->init(&tx, stream_id);
+  stream->init(&tx, 0, stream_id);
   stream->do_io_read(nullptr, 0, read_buffer);
 
   stream->recv(frame_8);
@@ -102,7 +102,7 @@ TEST_CASE("QUICStream_assembling_byte_stream_3", "[quic]")
   MockQUICFrameTransmitter tx;
 
   std::unique_ptr<QUICStream> stream(new QUICStream());
-  stream->init(&tx, stream_id);
+  stream->init(&tx, 0, stream_id);
   stream->do_io_read(nullptr, 0, read_buffer);
 
   stream->recv(frame_8);
diff --git a/iocore/net/quic/test/test_QUICStreamManager.cc b/iocore/net/quic/test/test_QUICStreamManager.cc
index 1a14a36..f9490c9 100644
--- a/iocore/net/quic/test/test_QUICStreamManager.cc
+++ b/iocore/net/quic/test/test_QUICStreamManager.cc
@@ -35,7 +35,7 @@ TEST_CASE("QUICStreamManager_NewStream", "[quic]")
   QUICApplicationMap app_map;
   MockQUICApplication mock_app;
   app_map.set_default(&mock_app);
-  QUICStreamManager sm(&tx, &app_map);
+  QUICStreamManager sm(0, &tx, &app_map);
   std::shared_ptr<QUICTransportParameters> local_tp = std::make_shared<QUICTransportParametersInEncryptedExtensions>();
   std::shared_ptr<QUICTransportParameters> remote_tp =
     std::make_shared<QUICTransportParametersInClientHello>(static_cast<QUICVersion>(0), static_cast<QUICVersion>(0));
@@ -80,7 +80,7 @@ TEST_CASE("QUICStreamManager_first_initial_map", "[quic]")
   QUICApplicationMap app_map;
   MockQUICApplication mock_app;
   app_map.set_default(&mock_app);
-  QUICStreamManager sm(&tx, &app_map);
+  QUICStreamManager sm(0, &tx, &app_map);
   std::shared_ptr<QUICTransportParameters> local_tp = std::make_shared<QUICTransportParametersInEncryptedExtensions>();
   std::shared_ptr<QUICTransportParameters> remote_tp =
     std::make_shared<QUICTransportParametersInClientHello>(static_cast<QUICVersion>(0), static_cast<QUICVersion>(0));
@@ -100,7 +100,7 @@ TEST_CASE("QUICStreamManager_total_offset_received", "[quic]")
   QUICApplicationMap app_map;
   MockQUICApplication mock_app;
   app_map.set_default(&mock_app);
-  QUICStreamManager sm(&tx, &app_map);
+  QUICStreamManager sm(0, &tx, &app_map);
   std::shared_ptr<QUICTransportParameters> local_tp = std::make_shared<QUICTransportParametersInEncryptedExtensions>();
   local_tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA,
                 std::unique_ptr<QUICTransportParameterValue>(new QUICTransportParameterValue(4096, 4)));
@@ -134,7 +134,7 @@ TEST_CASE("QUICStreamManager_total_offset_sent", "[quic]")
   QUICApplicationMap app_map;
   MockQUICApplication mock_app;
   app_map.set_default(&mock_app);
-  QUICStreamManager sm(&tx, &app_map);
+  QUICStreamManager sm(0, &tx, &app_map);
   std::shared_ptr<QUICTransportParameters> local_tp = std::make_shared<QUICTransportParametersInEncryptedExtensions>();
   local_tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA,
                 std::unique_ptr<QUICTransportParameterValue>(new QUICTransportParameterValue(4096, 4)));

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