This is an automated email from the ASF dual-hosted git repository.
bcall 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 bf3fa57 Fixed memory leak in the QUIC stream manager (#7951)
bf3fa57 is described below
commit bf3fa57a4ff5c291aff06ef688c909e80f45b9b5
Author: Bryan Call <[email protected]>
AuthorDate: Fri Jun 18 16:04:04 2021 -0700
Fixed memory leak in the QUIC stream manager (#7951)
* Fixed memory leak in the QUIC stream manager.
Removed the proxy allocator for the streams. They can be added
back in if there is a performance issue.
---
iocore/eventsystem/I_Thread.h | 3 ---
iocore/net/quic/QUICStreamFactory.cc | 36 ++++--------------------------------
iocore/net/quic/QUICStreamManager.cc | 7 +++++++
iocore/net/quic/QUICStreamManager.h | 1 +
4 files changed, 12 insertions(+), 35 deletions(-)
diff --git a/iocore/eventsystem/I_Thread.h b/iocore/eventsystem/I_Thread.h
index f2f1b1c..7ec7c3e 100644
--- a/iocore/eventsystem/I_Thread.h
+++ b/iocore/eventsystem/I_Thread.h
@@ -123,9 +123,6 @@ public:
ProxyAllocator http2ClientSessionAllocator;
ProxyAllocator http2StreamAllocator;
ProxyAllocator quicClientSessionAllocator;
- ProxyAllocator quicBidiStreamAllocator;
- ProxyAllocator quicSendStreamAllocator;
- ProxyAllocator quicReceiveStreamAllocator;
ProxyAllocator httpServerSessionAllocator;
ProxyAllocator hdrHeapAllocator;
ProxyAllocator strHeapAllocator;
diff --git a/iocore/net/quic/QUICStreamFactory.cc
b/iocore/net/quic/QUICStreamFactory.cc
index 9762895..548be10 100644
--- a/iocore/net/quic/QUICStreamFactory.cc
+++ b/iocore/net/quic/QUICStreamFactory.cc
@@ -26,30 +26,20 @@
#include "QUICUnidirectionalStream.h"
#include "QUICStreamFactory.h"
-ClassAllocator<QUICBidirectionalStream>
quicBidiStreamAllocator("quicBidiStreamAllocator");
-ClassAllocator<QUICSendStream>
quicSendStreamAllocator("quicSendStreamAllocator");
-ClassAllocator<QUICReceiveStream>
quicReceiveStreamAllocator("quicReceiveStreamAllocator");
-
QUICStreamVConnection *
QUICStreamFactory::create(QUICStreamId sid, uint64_t local_max_stream_data,
uint64_t remote_max_stream_data)
{
QUICStreamVConnection *stream = nullptr;
switch (QUICTypeUtil::detect_stream_direction(sid,
this->_info->direction())) {
case QUICStreamDirection::BIDIRECTIONAL:
- // TODO Free the stream somewhere
- stream = THREAD_ALLOC(quicBidiStreamAllocator, this_ethread());
- new (stream) QUICBidirectionalStream(this->_rtt_provider, this->_info,
sid, local_max_stream_data, remote_max_stream_data);
+ stream = new QUICBidirectionalStream(this->_rtt_provider, this->_info,
sid, local_max_stream_data, remote_max_stream_data);
break;
case QUICStreamDirection::SEND:
- // TODO Free the stream somewhere
- stream = THREAD_ALLOC(quicSendStreamAllocator, this_ethread());
- new (stream) QUICSendStream(this->_info, sid, remote_max_stream_data);
+ stream = new QUICSendStream(this->_info, sid, remote_max_stream_data);
break;
case QUICStreamDirection::RECEIVE:
// server side
- // TODO Free the stream somewhere
- stream = THREAD_ALLOC(quicReceiveStreamAllocator, this_ethread());
- new (stream) QUICReceiveStream(this->_rtt_provider, this->_info, sid,
local_max_stream_data);
+ stream = new QUICReceiveStream(this->_rtt_provider, this->_info, sid,
local_max_stream_data);
break;
default:
ink_assert(false);
@@ -62,23 +52,5 @@ QUICStreamFactory::create(QUICStreamId sid, uint64_t
local_max_stream_data, uint
void
QUICStreamFactory::delete_stream(QUICStreamVConnection *stream)
{
- if (!stream) {
- return;
- }
-
- stream->~QUICStreamVConnection();
- switch (stream->direction()) {
- case QUICStreamDirection::BIDIRECTIONAL:
- THREAD_FREE(static_cast<QUICBidirectionalStream *>(stream),
quicBidiStreamAllocator, this_thread());
- break;
- case QUICStreamDirection::SEND:
- THREAD_FREE(static_cast<QUICSendStream *>(stream),
quicSendStreamAllocator, this_thread());
- break;
- case QUICStreamDirection::RECEIVE:
- THREAD_FREE(static_cast<QUICReceiveStream *>(stream),
quicReceiveStreamAllocator, this_thread());
- break;
- default:
- ink_assert(false);
- break;
- }
+ delete stream;
}
diff --git a/iocore/net/quic/QUICStreamManager.cc
b/iocore/net/quic/QUICStreamManager.cc
index da66d74..54a6d20 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -41,6 +41,13 @@ QUICStreamManager::QUICStreamManager(QUICContext *context,
QUICApplicationMap *a
}
}
+QUICStreamManager::~QUICStreamManager()
+{
+ for (auto stream = stream_list.pop(); stream != nullptr; stream =
stream_list.pop()) {
+ _stream_factory.delete_stream(stream);
+ }
+}
+
std::vector<QUICFrameType>
QUICStreamManager::interests()
{
diff --git a/iocore/net/quic/QUICStreamManager.h
b/iocore/net/quic/QUICStreamManager.h
index 05da5fc..f158035 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -40,6 +40,7 @@ class QUICStreamManager : public QUICFrameHandler, public
QUICFrameGenerator
{
public:
QUICStreamManager(QUICContext *context, QUICApplicationMap *app_map);
+ ~QUICStreamManager();
void init_flow_control_params(const std::shared_ptr<const
QUICTransportParameters> &local_tp,
const std::shared_ptr<const
QUICTransportParameters> &remote_tp);