trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mas...@apache.org
Subject [trafficserver] 03/03: Remove dependency for NetVConnection
Date Mon, 14 Aug 2017 08:34:34 GMT
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

commit e4d34d77238292453ee3358e7d4f0bd8f61c3dcb
Author: Masakazu Kitajo <maskit@apache.org>
AuthorDate: Mon Aug 14 17:30:18 2017 +0900

    Remove dependency for NetVConnection
    
    To make it possible to run test without real network layer, QUIC related classes
    depend on QUICConnection abstraction layer instead of QUICNetVConnection.
---
 iocore/net/P_QUICNetVConnection.h                |  9 +++++----
 iocore/net/quic/Mock.h                           | 14 ++++++++++++++
 iocore/net/quic/QUICApplication.cc               |  4 ++--
 iocore/net/quic/QUICApplication.h                |  9 +++++----
 iocore/net/quic/QUICConnection.h                 |  7 +++++++
 iocore/net/quic/QUICEchoApp.cc                   |  3 +--
 iocore/net/quic/QUICEchoApp.h                    |  3 +--
 iocore/net/quic/QUICHandshake.cc                 | 18 +++++++-----------
 iocore/net/quic/QUICHandshake.h                  |  5 ++---
 iocore/net/quic/QUICStreamManager.cc             |  7 +++----
 iocore/net/quic/QUICStreamManager.h              |  7 +++----
 iocore/net/quic/test/test_QUICFrameDispatcher.cc | 17 -----------------
 iocore/net/quic/test/test_QUICStream.cc          | 17 -----------------
 13 files changed, 50 insertions(+), 70 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index 67fb93b..3eea803 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -156,16 +156,17 @@ public:
   uint32_t maximum_quic_packet_size();
   uint32_t minimum_quic_packet_size();
   void push_packet(std::unique_ptr<const QUICPacket> packet);
-  void close(QUICError error);
   void free(EThread *t) override;
 
   UDPConnection *get_udp_con();
-  QUICApplication *get_application(QUICStreamId stream_id);
-  QUICCrypto *get_crypto();
-
   virtual void net_read_io(NetHandler *nh, EThread *lthread) override;
   virtual int64_t load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf, int64_t
&total_written, int &needs) override;
 
+  // QUICConnection
+  QUICApplication *get_application(QUICStreamId stream_id) override;
+  QUICCrypto *get_crypto() override;
+  void close(QUICError error) override;
+
   // QUICConnection (QUICPacketTransmitter)
   virtual void transmit_packet(std::unique_ptr<const QUICPacket> packet) override;
   virtual void retransmit_packet(const QUICPacket &packet) override;
diff --git a/iocore/net/quic/Mock.h b/iocore/net/quic/Mock.h
index 164b808..42b3c7b 100644
--- a/iocore/net/quic/Mock.h
+++ b/iocore/net/quic/Mock.h
@@ -38,6 +38,20 @@ public:
   {
   }
 
+  QUICApplication *get_application(QUICStreamId stream_id) override
+  {
+    return nullptr;
+  }
+
+  QUICCrypto *get_crypto() override
+  {
+    return nullptr;
+  }
+
+  void close(QUICError error) override
+  {
+  }
+
   int
   getTotalFrameCount()
   {
diff --git a/iocore/net/quic/QUICApplication.cc b/iocore/net/quic/QUICApplication.cc
index 343a6be..6acbfb7 100644
--- a/iocore/net/quic/QUICApplication.cc
+++ b/iocore/net/quic/QUICApplication.cc
@@ -81,9 +81,9 @@ QUICStreamIO::write_reenable()
 //
 // QUICApplication
 //
-QUICApplication::QUICApplication(ProxyMutex *m, QUICNetVConnection *vc) : Continuation(m)
+QUICApplication::QUICApplication(ProxyMutex *m, QUICConnection *qc) : Continuation(m)
 {
-  this->_client_vc = vc;
+  this->_client_qc = qc;
 }
 
 // @brief Bind stream and application
diff --git a/iocore/net/quic/QUICApplication.h b/iocore/net/quic/QUICApplication.h
index d876e6a..cc075fe 100644
--- a/iocore/net/quic/QUICApplication.h
+++ b/iocore/net/quic/QUICApplication.h
@@ -23,10 +23,11 @@
 
 #pragma once
 
-#include "I_VConnection.h"
+#include "../../eventsystem/I_EventSystem.h"
+#include "../../eventsystem/I_IOBuffer.h"
 #include "QUICTypes.h"
 
-class QUICNetVConnection;
+class QUICConnection;
 class QUICStream;
 class QUICApplication;
 
@@ -62,7 +63,7 @@ private:
 class QUICApplication : public Continuation
 {
 public:
-  QUICApplication(ProxyMutex *m, QUICNetVConnection *vc);
+  QUICApplication(ProxyMutex *m, QUICConnection *qc);
 
   void set_stream(QUICStream *stream);
   bool is_stream_set(QUICStream *stream);
@@ -72,7 +73,7 @@ public:
 protected:
   QUICStreamIO *_find_stream_io(QUICStreamId id);
 
-  QUICNetVConnection *_client_vc = nullptr;
+  QUICConnection *_client_qc = nullptr;
 
 private:
   std::map<QUICStreamId, QUICStreamIO *> _stream_map;
diff --git a/iocore/net/quic/QUICConnection.h b/iocore/net/quic/QUICConnection.h
index bf71ba8..236842b 100644
--- a/iocore/net/quic/QUICConnection.h
+++ b/iocore/net/quic/QUICConnection.h
@@ -27,6 +27,13 @@
 #include "QUICFrameTransmitter.h"
 #include "QUICFrameHandler.h"
 
+class QUICApplication;
+class QUICCrypto;
+
 class QUICConnection : public QUICPacketTransmitter, public QUICFrameTransmitter, public
QUICFrameHandler
 {
+public:
+  virtual QUICApplication *get_application(QUICStreamId stream_id) = 0;
+  virtual QUICCrypto *get_crypto() = 0;
+  virtual void close(QUICError error) = 0;
 };
diff --git a/iocore/net/quic/QUICEchoApp.cc b/iocore/net/quic/QUICEchoApp.cc
index 45bb4f9..4be18cc 100644
--- a/iocore/net/quic/QUICEchoApp.cc
+++ b/iocore/net/quic/QUICEchoApp.cc
@@ -24,12 +24,11 @@
 #include "QUICEchoApp.h"
 
 #include "P_Net.h"
-#include "P_QUICNetVConnection.h"
 #include "QUICDebugNames.h"
 
 const static char *tag = "quic_echo_app";
 
-QUICEchoApp::QUICEchoApp(ProxyMutex *m, QUICNetVConnection *vc) : QUICApplication(m, vc)
+QUICEchoApp::QUICEchoApp(ProxyMutex *m, QUICConnection *qc) : QUICApplication(m, qc)
 {
   SET_HANDLER(&QUICEchoApp::main_event_handler);
 }
diff --git a/iocore/net/quic/QUICEchoApp.h b/iocore/net/quic/QUICEchoApp.h
index a8310b7..541da29 100644
--- a/iocore/net/quic/QUICEchoApp.h
+++ b/iocore/net/quic/QUICEchoApp.h
@@ -24,7 +24,6 @@
 #ifndef __QUIC_ECHOAPP__
 #define __QUIC_ECHOAPP__
 
-#include "I_VConnection.h"
 #include "QUICApplication.h"
 
 /**
@@ -35,7 +34,7 @@
 class QUICEchoApp : public QUICApplication
 {
 public:
-  QUICEchoApp(ProxyMutex *m, QUICNetVConnection *vc);
+  QUICEchoApp(ProxyMutex *m, QUICConnection *qc);
 
   int main_event_handler(int event, Event *data);
 };
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index f5b0753..067a3c0 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -23,10 +23,6 @@
 
 #include "QUICHandshake.h"
 
-#include "P_Net.h"
-#include "P_QUICNetVConnection.h"
-#include "QUICApplication.h"
-
 #define I_WANNA_DUMP_THIS_BUF(buf, len)                                                 
                                         \
   {                                                                                     
                                         \
     int i, j;                                                                           
                                         \
@@ -52,7 +48,7 @@ const static int UDP_MAXIMUM_PAYLOAD_SIZE = 65527;
 // TODO: fix size
 const static int MAX_HANDSHAKE_MSG_LEN = 65527;
 
-QUICHandshake::QUICHandshake(ProxyMutex *m, QUICNetVConnection *vc) : QUICApplication(m,
vc)
+QUICHandshake::QUICHandshake(ProxyMutex *m, QUICConnection *qc) : QUICApplication(m, qc)
 {
   SET_HANDLER(&QUICHandshake::state_read_client_hello);
 }
@@ -60,7 +56,7 @@ QUICHandshake::QUICHandshake(ProxyMutex *m, QUICNetVConnection *vc) : QUICApplic
 bool
 QUICHandshake::is_completed()
 {
-  QUICCrypto *crypto = this->_client_vc->get_crypto();
+  QUICCrypto *crypto = this->_client_qc->get_crypto();
   return crypto->is_handshake_finished();
 }
 
@@ -87,7 +83,7 @@ QUICHandshake::state_read_client_hello(int event, Event *data)
   }
 
   if (error.cls != QUICErrorClass::NONE) {
-    this->_client_vc->close(error);
+    this->_client_qc->close(error);
     Debug(tag, "Enter state_closed");
     SET_HANDLER(&QUICHandshake::state_closed);
   }
@@ -111,7 +107,7 @@ QUICHandshake::state_read_client_finished(int event, Event *data)
   }
 
   if (error.cls != QUICErrorClass::NONE) {
-    this->_client_vc->close(error);
+    this->_client_qc->close(error);
     Debug(tag, "Enter state_closed");
     SET_HANDLER(&QUICHandshake::state_closed);
   }
@@ -160,7 +156,7 @@ QUICHandshake::_process_client_hello()
   I_WANNA_DUMP_THIS_BUF(msg, msg_len);
   // <----- DEBUG -----
 
-  QUICCrypto *crypto = this->_client_vc->get_crypto();
+  QUICCrypto *crypto = this->_client_qc->get_crypto();
 
   uint8_t server_hello[MAX_HANDSHAKE_MSG_LEN] = {0};
   size_t server_hello_len                     = 0;
@@ -204,7 +200,7 @@ QUICHandshake::_process_client_finished()
   I_WANNA_DUMP_THIS_BUF(msg, msg_len);
   // <----- DEBUG -----
 
-  QUICCrypto *crypto = this->_client_vc->get_crypto();
+  QUICCrypto *crypto = this->_client_qc->get_crypto();
 
   uint8_t out[MAX_HANDSHAKE_MSG_LEN] = {0};
   size_t out_len                     = 0;
@@ -236,7 +232,7 @@ QUICHandshake::_process_client_finished()
 QUICError
 QUICHandshake::_process_handshake_complete()
 {
-  QUICCrypto *crypto = this->_client_vc->get_crypto();
+  QUICCrypto *crypto = this->_client_qc->get_crypto();
   int r              = crypto->setup_session();
 
   if (r) {
diff --git a/iocore/net/quic/QUICHandshake.h b/iocore/net/quic/QUICHandshake.h
index 28854ec..cd2a359 100644
--- a/iocore/net/quic/QUICHandshake.h
+++ b/iocore/net/quic/QUICHandshake.h
@@ -24,10 +24,9 @@
 #ifndef __QUIC_HANDSHAKE__
 #define __QUIC_HANDSHAKE__
 
-#include "I_VConnection.h"
+#include "QUICConnection.h"
 #include "QUICApplication.h"
 
-class QUICNetVConnection;
 
 /**
  * @class QUICHandshake
@@ -49,7 +48,7 @@ class QUICNetVConnection;
 class QUICHandshake : public QUICApplication
 {
 public:
-  QUICHandshake(ProxyMutex *m, QUICNetVConnection *vc);
+  QUICHandshake(ProxyMutex *m, QUICConnection *qc);
 
   int state_read_client_hello(int event, Event *data);
   int state_read_client_finished(int event, Event *data);
diff --git a/iocore/net/quic/QUICStreamManager.cc b/iocore/net/quic/QUICStreamManager.cc
index 6499772..e9f058d 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -24,7 +24,6 @@
 #include <QUICStreamManager.h>
 
 #include <QUICApplication.h>
-#include <P_QUICNetVConnection.h>
 
 const static char *tag = "quic_stream_manager";
 
@@ -39,9 +38,9 @@ QUICStreamManager::init(QUICFrameTransmitter *tx)
 }
 
 void
-QUICStreamManager::set_connection(QUICNetVConnection *vc)
+QUICStreamManager::set_connection(QUICConnection *qc)
 {
-  this->_vc = vc;
+  this->_qc = qc;
 }
 
 void
@@ -62,7 +61,7 @@ void
 QUICStreamManager::_handle_stream_frame(std::shared_ptr<const QUICStreamFrame> frame)
 {
   QUICStream *stream           = this->_find_or_create_stream(frame->stream_id());
-  QUICApplication *application = this->_vc->get_application(frame->stream_id());
+  QUICApplication *application = this->_qc->get_application(frame->stream_id());
 
   if (!application->is_stream_set(stream)) {
     application->set_stream(stream);
diff --git a/iocore/net/quic/QUICStreamManager.h b/iocore/net/quic/QUICStreamManager.h
index 3daff59..1b03166 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -25,19 +25,18 @@
 
 #include "QUICTypes.h"
 #include "QUICStream.h"
+#include "QUICConnection.h"
 #include "QUICFrameHandler.h"
 #include "QUICFrame.h"
 #include "QUICFrameTransmitter.h"
 
-class QUICNetVConnection;
-
 class QUICStreamManager : public QUICFrameHandler
 {
 public:
   QUICStreamManager(){};
 
   int init(QUICFrameTransmitter *tx);
-  void set_connection(QUICNetVConnection *vc); // FIXME Want to remove.
+  void set_connection(QUICConnection *qc); // FIXME Want to remove.
   virtual void handle_frame(std::shared_ptr<const QUICFrame>) override;
   void send_frame(std::unique_ptr<QUICFrame, QUICFrameDeleterFunc> frame);
 
@@ -47,7 +46,7 @@ private:
   QUICStream *_find_or_create_stream(QUICStreamId stream_id);
   QUICStream *_find_stream(QUICStreamId id);
 
-  QUICNetVConnection *_vc   = nullptr;
+  QUICConnection *_qc   = nullptr;
   QUICFrameTransmitter *_tx = nullptr;
 
 private:
diff --git a/iocore/net/quic/test/test_QUICFrameDispatcher.cc b/iocore/net/quic/test/test_QUICFrameDispatcher.cc
index 6f5f052..53726a7 100644
--- a/iocore/net/quic/test/test_QUICFrameDispatcher.cc
+++ b/iocore/net/quic/test/test_QUICFrameDispatcher.cc
@@ -55,20 +55,3 @@ TEST_CASE("QUICFrameHandler", "[quic]")
   CHECK(flowController->getTotalFrameCount() == 1);
   CHECK(congestionController->getTotalFrameCount() == 1);
 }
-
-// Stubs
-QUICApplication *QUICNetVConnection::get_application(QUICStreamId)
-{
-  return nullptr;
-}
-
-QUICCrypto *
-QUICNetVConnection::get_crypto()
-{
-  return nullptr;
-}
-
-void QUICNetVConnection::close(QUICError)
-{
-  return;
-}
diff --git a/iocore/net/quic/test/test_QUICStream.cc b/iocore/net/quic/test/test_QUICStream.cc
index 042f39d..e31ddb9 100644
--- a/iocore/net/quic/test/test_QUICStream.cc
+++ b/iocore/net/quic/test/test_QUICStream.cc
@@ -121,20 +121,3 @@ TEST_CASE("QUICStream_assembling_byte_stream_3", "[quic]")
   CHECK(memcmp(buf, payload, len) == 0);
 }
 }
-
-// Stubs
-QUICApplication *QUICNetVConnection::get_application(QUICStreamId)
-{
-  return nullptr;
-}
-
-QUICCrypto *
-QUICNetVConnection::get_crypto()
-{
-  return nullptr;
-}
-
-void QUICNetVConnection::close(QUICError)
-{
-  return;
-}

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

Mime
View raw message