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/08/28 07:27:31 UTC

[trafficserver] 01/02: Allocate QUICPacket with a class allocator

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 b9570de8dabe46f8a0f7b8fa8eae5e219d1827a2
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Mon Aug 28 15:49:24 2017 +0900

    Allocate QUICPacket with a class allocator
---
 iocore/net/P_QUICNetVConnection.h                  | 16 +++----
 iocore/net/QUICNetVConnection.cc                   | 27 ++++++------
 iocore/net/QUICPacketHandler.cc                    |  4 +-
 iocore/net/quic/Mock.h                             |  6 +--
 iocore/net/quic/QUICLossDetector.cc                |  4 +-
 iocore/net/quic/QUICLossDetector.h                 |  6 +--
 iocore/net/quic/QUICPacket.cc                      | 50 ++++++++++++----------
 iocore/net/quic/QUICPacket.h                       | 40 +++++++++++++----
 iocore/net/quic/QUICPacketTransmitter.h            |  2 +-
 iocore/net/quic/QUICTransportParameters.cc         |  8 ++--
 iocore/net/quic/QUICTransportParameters.h          |  4 +-
 iocore/net/quic/test/test_QUICLossDetector.cc      |  6 ++-
 iocore/net/quic/test/test_QUICPacketFactory.cc     |  5 ++-
 iocore/net/quic/test/test_QUICVersionNegotiator.cc |  2 +-
 14 files changed, 109 insertions(+), 71 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index bfb96af..b370cc5 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -157,7 +157,7 @@ public:
   int state_connection_closing(int event, Event *data);
   int state_connection_closed(int event, Event *data);
   void start(SSL_CTX *);
-  void push_packet(std::unique_ptr<const QUICPacket> packet);
+  void push_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet);
   void free(EThread *t) override;
 
   UDPConnection *get_udp_con();
@@ -177,7 +177,7 @@ public:
   void close(QUICError error) override;
 
   // QUICConnection (QUICPacketTransmitter)
-  virtual void transmit_packet(std::unique_ptr<const QUICPacket> packet) override;
+  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;
 
@@ -216,15 +216,15 @@ private:
   std::queue<std::unique_ptr<QUICFrame, QUICFrameDeleterFunc>> _frame_buffer;
 
   void _packetize_frames();
-  std::unique_ptr<QUICPacket> _build_packet(ats_unique_buf buf, size_t len, bool retransmittable,
-                                            QUICPacketType type = QUICPacketType::UNINITIALIZED);
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> _build_packet(ats_unique_buf buf, size_t len, bool retransmittable,
+                                                                   QUICPacketType type = QUICPacketType::UNINITIALIZED);
 
   QUICError _recv_and_ack(const uint8_t *payload, uint16_t size, QUICPacketNumber packet_numm);
 
-  QUICError _state_handshake_process_initial_client_packet(std::unique_ptr<const QUICPacket> packet);
-  QUICError _state_handshake_process_client_cleartext_packet(std::unique_ptr<const QUICPacket> packet);
-  QUICError _state_handshake_process_zero_rtt_protected_packet(std::unique_ptr<const QUICPacket> packet);
-  QUICError _state_connection_established_process_packet(std::unique_ptr<const QUICPacket> packet);
+  QUICError _state_handshake_process_initial_client_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet);
+  QUICError _state_handshake_process_client_cleartext_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet);
+  QUICError _state_handshake_process_zero_rtt_protected_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet);
+  QUICError _state_connection_established_process_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet);
   QUICError _state_common_receive_packet();
   QUICError _state_common_send_packet();
 
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 99e63da..8bb0601 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -184,7 +184,7 @@ QUICNetVConnection::maximum_stream_frame_data_size()
 }
 
 void
-QUICNetVConnection::transmit_packet(std::unique_ptr<const QUICPacket> packet)
+QUICNetVConnection::transmit_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   // TODO Remove const_cast
   this->_packet_send_queue.enqueue(const_cast<QUICPacket *>(packet.release()));
@@ -223,7 +223,7 @@ QUICNetVConnection::get_transmitter_mutex()
 }
 
 void
-QUICNetVConnection::push_packet(std::unique_ptr<QUICPacket const> packet)
+QUICNetVConnection::push_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   DebugQUICCon("Type=%s Size=%u", QUICDebugNames::packet_type(packet->type()), packet->size());
   this->_packet_recv_queue.enqueue(const_cast<QUICPacket *>(packet.release()));
@@ -306,7 +306,8 @@ QUICNetVConnection::state_handshake(int event, Event *data)
 
   switch (event) {
   case QUIC_EVENT_PACKET_READ_READY: {
-    std::unique_ptr<const QUICPacket> p = std::unique_ptr<const QUICPacket>(this->_packet_recv_queue.dequeue());
+    std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> p =
+      std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(this->_packet_recv_queue.dequeue(), &QUICPacketDeleter::delete_packet);
     net_activity(this, this_ethread());
 
     switch (p->type()) {
@@ -489,7 +490,7 @@ QUICNetVConnection::next_protocol_set()
 }
 
 QUICError
-QUICNetVConnection::_state_handshake_process_initial_client_packet(std::unique_ptr<const QUICPacket> packet)
+QUICNetVConnection::_state_handshake_process_initial_client_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   if (packet->size() < this->minimum_quic_packet_size()) {
     DebugQUICCon("%" PRId32 ", %" PRId32, packet->size(), this->minimum_quic_packet_size());
@@ -512,7 +513,7 @@ QUICNetVConnection::_state_handshake_process_initial_client_packet(std::unique_p
 }
 
 QUICError
-QUICNetVConnection::_state_handshake_process_client_cleartext_packet(std::unique_ptr<const QUICPacket> packet)
+QUICNetVConnection::_state_handshake_process_client_cleartext_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   QUICError error = QUICError(QUICErrorClass::NONE);
 
@@ -527,7 +528,7 @@ QUICNetVConnection::_state_handshake_process_client_cleartext_packet(std::unique
 }
 
 QUICError
-QUICNetVConnection::_state_handshake_process_zero_rtt_protected_packet(std::unique_ptr<const QUICPacket> packet)
+QUICNetVConnection::_state_handshake_process_zero_rtt_protected_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   // TODO: Decrypt the packet
   // decrypt(payload, p);
@@ -536,7 +537,7 @@ QUICNetVConnection::_state_handshake_process_zero_rtt_protected_packet(std::uniq
 }
 
 QUICError
-QUICNetVConnection::_state_connection_established_process_packet(std::unique_ptr<const QUICPacket> packet)
+QUICNetVConnection::_state_connection_established_process_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   // TODO: fix size
   size_t max_plain_txt_len = 2048;
@@ -560,7 +561,8 @@ QUICError
 QUICNetVConnection::_state_common_receive_packet()
 {
   QUICError error;
-  std::unique_ptr<const QUICPacket> p = std::unique_ptr<const QUICPacket>(this->_packet_recv_queue.dequeue());
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> p =
+    std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(this->_packet_recv_queue.dequeue(), &QUICPacketDeleter::delete_packet);
   net_activity(this, this_ethread());
 
   switch (p->type()) {
@@ -580,10 +582,11 @@ QUICNetVConnection::_state_common_send_packet()
 {
   this->_packetize_frames();
 
-  const QUICPacket *packet;
+  QUICPacket *packet;
   while ((packet = this->_packet_send_queue.dequeue()) != nullptr) {
     this->_packet_handler->send_packet(*packet, this);
-    this->_loss_detector->on_packet_sent(std::unique_ptr<const QUICPacket>(packet));
+    this->_loss_detector->on_packet_sent(
+      std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(packet, &QUICPacketDeleter::delete_packet));
   }
 
   net_activity(this, this_ethread());
@@ -660,10 +663,10 @@ QUICNetVConnection::_recv_and_ack(const uint8_t *payload, uint16_t size, QUICPac
   return error;
 }
 
-std::unique_ptr<QUICPacket>
+std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>
 QUICNetVConnection::_build_packet(ats_unique_buf buf, size_t len, bool retransmittable, QUICPacketType type)
 {
-  std::unique_ptr<QUICPacket> packet;
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet(nullptr, &QUICPacketDeleter::delete_null_packet);
   DebugQUICCon("retransmittable %u", retransmittable);
 
   switch (type) {
diff --git a/iocore/net/QUICPacketHandler.cc b/iocore/net/QUICPacketHandler.cc
index 2edb338..0a7278c 100644
--- a/iocore/net/QUICPacketHandler.cc
+++ b/iocore/net/QUICPacketHandler.cc
@@ -96,8 +96,8 @@ QUICPacketHandler::_recv_packet(int event, UDPPacket *udpPacket)
 {
   IOBufferBlock *block = udpPacket->getIOBlockChain();
 
-  std::unique_ptr<QUICPacket> qPkt = std::unique_ptr<QUICPacket>(QUICPacketFactory::create(block));
-  QUICNetVConnection *vc           = this->_connections.get(qPkt->connection_id());
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> qPkt = QUICPacketFactory::create(block);
+  QUICNetVConnection *vc = this->_connections.get(qPkt->connection_id());
 
   if (!vc) {
     // Unknown Connection ID
diff --git a/iocore/net/quic/Mock.h b/iocore/net/quic/Mock.h
index dad5f63..54ee271 100644
--- a/iocore/net/quic/Mock.h
+++ b/iocore/net/quic/Mock.h
@@ -100,7 +100,7 @@ public:
     this->_mutex = new_ProxyMutex();
   };
   void
-  transmit_packet(std::unique_ptr<const QUICPacket> packet) override
+  transmit_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet) override
   {
     ++_transmit_count;
   }
@@ -199,7 +199,7 @@ class MockQUICPacketTransmitter : public QUICPacketTransmitter
 public:
   MockQUICPacketTransmitter() : QUICPacketTransmitter() { this->_mutex = new_ProxyMutex(); };
   void
-  transmit_packet(std::unique_ptr<const QUICPacket> packet) override
+  transmit_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet) override
   {
     ++_transmit_count;
   }
@@ -245,7 +245,7 @@ public:
   }
 
   void
-  on_packet_sent(std::unique_ptr<const QUICPacket> packet)
+  on_packet_sent(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
   {
   }
 };
diff --git a/iocore/net/quic/QUICLossDetector.cc b/iocore/net/quic/QUICLossDetector.cc
index bec3c6f..cd8fefd 100644
--- a/iocore/net/quic/QUICLossDetector.cc
+++ b/iocore/net/quic/QUICLossDetector.cc
@@ -137,7 +137,7 @@ QUICLossDetector::_detect_lost_packets(QUICPacketNumber largest_acked_packet_num
 }
 
 void
-QUICLossDetector::on_packet_sent(std::unique_ptr<const QUICPacket> packet)
+QUICLossDetector::on_packet_sent(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   bool is_handshake   = false;
   QUICPacketType type = packet->type();
@@ -154,7 +154,7 @@ QUICLossDetector::on_packet_sent(std::unique_ptr<const QUICPacket> packet)
 
 void
 QUICLossDetector::_on_packet_sent(QUICPacketNumber packet_number, bool is_retransmittable, bool is_handshake, size_t sent_bytes,
-                                  std::unique_ptr<const QUICPacket> packet)
+                                  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet)
 {
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
   this->_largest_sent_packet      = packet_number;
diff --git a/iocore/net/quic/QUICLossDetector.h b/iocore/net/quic/QUICLossDetector.h
index 44e87a5..b12a293 100644
--- a/iocore/net/quic/QUICLossDetector.h
+++ b/iocore/net/quic/QUICLossDetector.h
@@ -47,7 +47,7 @@ public:
 
   std::vector<QUICFrameType> interests() override;
   virtual QUICError handle_frame(std::shared_ptr<const QUICFrame>) override;
-  void on_packet_sent(std::unique_ptr<const QUICPacket> packet);
+  void on_packet_sent(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet);
 
 private:
   struct PacketInfo {
@@ -56,7 +56,7 @@ private:
     bool retransmittable;
     bool handshake;
     size_t bytes;
-    std::unique_ptr<const QUICPacket> packet;
+    std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet;
   };
 
   bool _time_loss_detection = false;
@@ -94,7 +94,7 @@ private:
   void _decrement_packet_count(QUICPacketNumber packet_number);
 
   void _on_packet_sent(QUICPacketNumber packet_number, bool is_retransmittable, bool is_handshake, size_t sent_bytes,
-                       std::unique_ptr<const QUICPacket> packet);
+                       std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet);
   void _on_ack_received(const std::shared_ptr<const QUICAckFrame> &ack_frame);
   void _on_packet_acked(QUICPacketNumber acked_packet_number);
   void _update_rtt(uint32_t latest_rtt);
diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index db50384..0e037f4 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -24,6 +24,8 @@
 #include <ts/ink_assert.h>
 #include "QUICPacket.h"
 
+ClassAllocator<QUICPacket> quicPacketAllocator("quicPacketAllocator");
+
 static constexpr int OFFSET_CONNECTION_ID = 1;
 static constexpr int OFFSET_PACKET_NUMBER = 9;
 static constexpr int OFFSET_VERSION       = 13;
@@ -571,14 +573,15 @@ QUICPacket::set_protected_payload(ats_unique_buf cipher_txt, size_t cipher_txt_l
   this->_protected_payload_size = cipher_txt_len;
 }
 
-QUICPacket *
+std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>
 QUICPacketFactory::create(IOBufferBlock *block)
 {
-  // TODO: Use custom allocator
-  return new QUICPacket(block);
+  QUICPacket *packet = quicPacketAllocator.alloc();
+  new (packet) QUICPacket(block);
+  return std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(packet, &QUICPacketDeleter::delete_packet);
 }
 
-std::unique_ptr<QUICPacket>
+std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>
 QUICPacketFactory::create_version_negotiation_packet(const QUICPacket *packet_sent_by_client)
 {
   size_t len = sizeof(QUICVersion) * countof(QUIC_SUPPORTED_VERSIONS);
@@ -591,31 +594,32 @@ QUICPacketFactory::create_version_negotiation_packet(const QUICPacket *packet_se
     p += n;
   }
 
-  // TODO: Use custom allocator
-  return std::unique_ptr<QUICPacket>(new QUICPacket(QUICPacketType::VERSION_NEGOTIATION, packet_sent_by_client->connection_id(),
-                                                    packet_sent_by_client->packet_number(), packet_sent_by_client->version(),
-                                                    std::move(versions), len, false));
+  QUICPacket *packet = quicPacketAllocator.alloc();
+  new (packet)
+    QUICPacket(QUICPacketType::VERSION_NEGOTIATION, packet_sent_by_client->connection_id(), packet_sent_by_client->packet_number(),
+               packet_sent_by_client->version(), std::move(versions), len, false);
+  return std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(packet, QUICPacketDeleter::delete_packet);
 }
 
-std::unique_ptr<QUICPacket>
+std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>
 QUICPacketFactory::create_server_cleartext_packet(QUICConnectionId connection_id, ats_unique_buf payload, size_t len,
                                                   bool retransmittable)
 {
-  // TODO: Use custom allocator
-  return std::unique_ptr<QUICPacket>(new QUICPacket(QUICPacketType::SERVER_CLEARTEXT, connection_id,
-                                                    this->_packet_number_generator.next(), this->_version, std::move(payload), len,
-                                                    retransmittable));
+  QUICPacket *p = quicPacketAllocator.alloc();
+  new (p) QUICPacket(QUICPacketType::SERVER_CLEARTEXT, connection_id, this->_packet_number_generator.next(), this->_version,
+                     std::move(payload), len, retransmittable);
+  return std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(p, &QUICPacketDeleter::delete_packet);
 }
 
-std::unique_ptr<QUICPacket>
+std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>
 QUICPacketFactory::create_server_protected_packet(QUICConnectionId connection_id, ats_unique_buf payload, size_t len,
                                                   bool retransmittable)
 {
   // TODO Key phase should be picked up from QUICCrypto, probably
-  // TODO Use class allocator
-  auto packet =
-    std::unique_ptr<QUICPacket>(new QUICPacket(QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_0, connection_id,
-                                               this->_packet_number_generator.next(), std::move(payload), len, retransmittable));
+  QUICPacket *p = quicPacketAllocator.alloc();
+  new (p) QUICPacket(QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_0, connection_id, this->_packet_number_generator.next(),
+                     std::move(payload), len, retransmittable);
+  auto packet = std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(p, &QUICPacketDeleter::delete_packet);
 
   // TODO: use pmtu of UnixNetVConnection
   size_t max_cipher_txt_len = 2048;
@@ -635,16 +639,18 @@ QUICPacketFactory::create_server_protected_packet(QUICConnectionId connection_id
     return packet;
   } else {
     Debug("quic_packet_factory", "CRYPTOGRAPHIC Error");
-    return nullptr;
+    return std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(nullptr, &QUICPacketDeleter::delete_null_packet);
   }
 }
 
-std::unique_ptr<QUICPacket>
+std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>
 QUICPacketFactory::create_client_initial_packet(QUICConnectionId connection_id, QUICVersion version, ats_unique_buf payload,
                                                 size_t len)
 {
-  return std::unique_ptr<QUICPacket>(new QUICPacket(QUICPacketType::CLIENT_INITIAL, connection_id,
-                                                    this->_packet_number_generator.next(), version, std::move(payload), len, true));
+  QUICPacket *packet = quicPacketAllocator.alloc();
+  new (packet) QUICPacket(QUICPacketType::CLIENT_INITIAL, connection_id, this->_packet_number_generator.next(), version,
+                          std::move(payload), len, true);
+  return std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(packet, &QUICPacketDeleter::delete_packet);
 }
 
 void
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 32a087b..dd2c216 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -121,6 +121,7 @@ private:
 class QUICPacket
 {
 public:
+  QUICPacket(){};
   QUICPacket(IOBufferBlock *block);
   QUICPacket(QUICPacketType type, QUICConnectionId connection_id, QUICPacketNumber packet_number, QUICVersion version,
              ats_unique_buf payload, size_t len, bool retransmittable);
@@ -164,17 +165,40 @@ private:
   QUICPacketNumber _current = 0;
 };
 
+using QUICPacketDeleterFunc = void (*)(QUICPacket *p);
+
+extern ClassAllocator<QUICPacket> quicPacketAllocator;
+
+class QUICPacketDeleter
+{
+public:
+  // TODO Probably these methods should call destructor
+  static void
+  delete_null_packet(QUICPacket *packet)
+  {
+  }
+
+  static void
+  delete_packet(QUICPacket *packet)
+  {
+    quicPacketAllocator.free(packet);
+  }
+};
+
 class QUICPacketFactory
 {
 public:
-  static QUICPacket *create(IOBufferBlock *block);
-  std::unique_ptr<QUICPacket> create_version_negotiation_packet(const QUICPacket *packet_sent_by_client);
-  std::unique_ptr<QUICPacket> create_server_cleartext_packet(QUICConnectionId connection_id, ats_unique_buf payload, size_t len,
-                                                             bool retransmittable);
-  std::unique_ptr<QUICPacket> create_server_protected_packet(QUICConnectionId connection_id, ats_unique_buf payload, size_t len,
-                                                             bool retransmittable);
-  std::unique_ptr<QUICPacket> create_client_initial_packet(QUICConnectionId connection_id, QUICVersion version,
-                                                           ats_unique_buf payload, size_t len);
+  static std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> create(IOBufferBlock *block);
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> create_version_negotiation_packet(const QUICPacket *packet_sent_by_client);
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> create_server_cleartext_packet(QUICConnectionId connection_id,
+                                                                                    ats_unique_buf payload, size_t len,
+                                                                                    bool retransmittable);
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> create_server_protected_packet(QUICConnectionId connection_id,
+                                                                                    ats_unique_buf payload, size_t len,
+                                                                                    bool retransmittable);
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> create_client_initial_packet(QUICConnectionId connection_id,
+                                                                                  QUICVersion version, ats_unique_buf payload,
+                                                                                  size_t len);
   void set_version(QUICVersion negotiated_version);
   void set_crypto_module(QUICCrypto *crypto);
 
diff --git a/iocore/net/quic/QUICPacketTransmitter.h b/iocore/net/quic/QUICPacketTransmitter.h
index d8b8a41..67c8fa5 100644
--- a/iocore/net/quic/QUICPacketTransmitter.h
+++ b/iocore/net/quic/QUICPacketTransmitter.h
@@ -33,7 +33,7 @@ public:
    *
    * This sends QUIC_PACKET_WRITE_READY event.
    */
-  virtual void transmit_packet(std::unique_ptr<const QUICPacket> packet) = 0;
+  virtual void transmit_packet(std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet) = 0;
 
   /*
    * Enqueue a packet for retransmission
diff --git a/iocore/net/quic/QUICTransportParameters.cc b/iocore/net/quic/QUICTransportParameters.cc
index c3ce09c..50c149f 100644
--- a/iocore/net/quic/QUICTransportParameters.cc
+++ b/iocore/net/quic/QUICTransportParameters.cc
@@ -162,11 +162,12 @@ QUICTransportParameters::store(uint8_t *buf, uint16_t *len) const
 // QUICTransportParametersInClientHello
 //
 
-QUICTransportParametersInClientHello::QUICTransportParametersInClientHello(const uint8_t *buf, size_t len) : QUICTransportParameters(buf, len)
+QUICTransportParametersInClientHello::QUICTransportParametersInClientHello(const uint8_t *buf, size_t len)
+  : QUICTransportParameters(buf, len)
 {
   // Print all parameters
   const uint8_t *p = this->_buf.get() + this->_parameters_offset();
-  uint16_t n = (p[0] << 8) + p[1];
+  uint16_t n       = (p[0] << 8) + p[1];
   p += 2;
   while (n > 0) {
     uint16_t _id = (p[0] << 8) + p[1];
@@ -178,7 +179,8 @@ QUICTransportParametersInClientHello::QUICTransportParametersInClientHello(const
     if (_value_len == 0) {
       Debug("quic_handsahke", "%s: (no value)", QUICDebugNames::transport_parameter_id(_id));
     } else if (_value_len <= 8) {
-      Debug("quic_handsahke", "%s: 0x%" PRIx64 " (%" PRIu64 ")", QUICDebugNames::transport_parameter_id(_id), QUICTypeUtil::read_nbytes_as_uint(p, _value_len), QUICTypeUtil::read_nbytes_as_uint(p, _value_len));
+      Debug("quic_handsahke", "%s: 0x%" PRIx64 " (%" PRIu64 ")", QUICDebugNames::transport_parameter_id(_id),
+            QUICTypeUtil::read_nbytes_as_uint(p, _value_len), QUICTypeUtil::read_nbytes_as_uint(p, _value_len));
     } else {
       Debug("quic_handsahke", "%s: (long data)", QUICDebugNames::transport_parameter_id(_id));
     }
diff --git a/iocore/net/quic/QUICTransportParameters.h b/iocore/net/quic/QUICTransportParameters.h
index c5239f2..87d8af6 100644
--- a/iocore/net/quic/QUICTransportParameters.h
+++ b/iocore/net/quic/QUICTransportParameters.h
@@ -99,8 +99,8 @@ protected:
 class QUICTransportParametersInClientHello : public QUICTransportParameters
 {
 public:
-  QUICTransportParametersInClientHello(QUICVersion negotiated_version, QUICVersion initial_version) : QUICTransportParameters(), _negotiated_version(negotiated_version), _initial_version(initial_version)
-{};
+  QUICTransportParametersInClientHello(QUICVersion negotiated_version, QUICVersion initial_version)
+    : QUICTransportParameters(), _negotiated_version(negotiated_version), _initial_version(initial_version){};
   QUICTransportParametersInClientHello(const uint8_t *buf, size_t len);
   QUICVersion negotiated_version() const;
   QUICVersion initial_version() const;
diff --git a/iocore/net/quic/test/test_QUICLossDetector.cc b/iocore/net/quic/test/test_QUICLossDetector.cc
index 09b4800..b23e156 100644
--- a/iocore/net/quic/test/test_QUICLossDetector.cc
+++ b/iocore/net/quic/test/test_QUICLossDetector.cc
@@ -40,8 +40,10 @@ TEST_CASE("QUICLossDetector_Loss_in_Handshake", "[quic]")
   ats_unique_buf payload = ats_unique_malloc(sizeof(raw));
   memcpy(payload.get(), raw, sizeof(raw));
 
-  std::unique_ptr<const QUICPacket> packet = std::unique_ptr<const QUICPacket>(new QUICPacket(
-    QUICPacketType::SERVER_CLEARTEXT, 0xffddbb9977553311ULL, 0x00000001, 0x00112233, std::move(payload), sizeof(raw), true));
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet = std::unique_ptr<QUICPacket, QUICPacketDeleterFunc>(
+    new QUICPacket(QUICPacketType::SERVER_CLEARTEXT, 0xffddbb9977553311ULL, 0x00000001, 0x00112233, std::move(payload), sizeof(raw),
+                   true),
+    [](QUICPacket *p) { delete p; });
   detector.on_packet_sent(std::move(packet));
   ink_hrtime_sleep(HRTIME_MSECONDS(1000));
   CHECK(tx->_retransmit_count > 0);
diff --git a/iocore/net/quic/test/test_QUICPacketFactory.cc b/iocore/net/quic/test/test_QUICPacketFactory.cc
index 31bdbd2..51850ff 100644
--- a/iocore/net/quic/test/test_QUICPacketFactory.cc
+++ b/iocore/net/quic/test/test_QUICPacketFactory.cc
@@ -44,7 +44,7 @@ TEST_CASE("QUICPacketFactory_Create_VersionNegotiationPacket", "[quic]")
 
   QUICPacket client_initial_packet(block);
 
-  std::unique_ptr<QUICPacket> packet = factory.create_version_negotiation_packet(&client_initial_packet);
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet = factory.create_version_negotiation_packet(&client_initial_packet);
   CHECK(packet->type() == QUICPacketType::VERSION_NEGOTIATION);
   CHECK(packet->connection_id() == client_initial_packet.connection_id());
   CHECK(packet->packet_number() == client_initial_packet.packet_number());
@@ -60,7 +60,8 @@ TEST_CASE("QUICPacketFactory_Create_ServerCleartextPacket", "[quic]")
   ats_unique_buf payload = ats_unique_malloc(sizeof(raw));
   memcpy(payload.get(), raw, sizeof(raw));
 
-  std::unique_ptr<QUICPacket> packet = factory.create_server_cleartext_packet(0x01020304, std::move(payload), sizeof(raw), true);
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> packet =
+    factory.create_server_cleartext_packet(0x01020304, std::move(payload), sizeof(raw), true);
   CHECK(packet->type() == QUICPacketType::SERVER_CLEARTEXT);
   CHECK(packet->connection_id() == 0x01020304);
   CHECK(memcmp(packet->payload(), raw, sizeof(raw)) == 0);
diff --git a/iocore/net/quic/test/test_QUICVersionNegotiator.cc b/iocore/net/quic/test/test_QUICVersionNegotiator.cc
index 1191efd..9de0bdb 100644
--- a/iocore/net/quic/test/test_QUICVersionNegotiator.cc
+++ b/iocore/net/quic/test/test_QUICVersionNegotiator.cc
@@ -35,7 +35,7 @@ TEST_CASE("QUICVersionNegotiator_Normal", "[quic]")
   CHECK(vn.status() == QUICVersionNegotiationStatus::NOT_NEGOTIATED);
 
   // Negotiate version
-  std::unique_ptr<QUICPacket> initial_packet =
+  std::unique_ptr<QUICPacket, QUICPacketDeleterFunc> initial_packet =
     packet_factory.create_client_initial_packet({}, QUIC_SUPPORTED_VERSIONS[0], ats_unique_malloc(0), 0);
   vn.negotiate(initial_packet.get());
   CHECK(vn.status() == QUICVersionNegotiationStatus::NEGOTIATED);

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