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 2018/08/28 02:02:48 UTC
[trafficserver] 02/03: QUICFrameHandler accepts frame as reference
but not as smart pointer
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 346940d7e15ccd69c20a948476c4386b6b6433b7
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Aug 28 10:32:29 2018 +0900
QUICFrameHandler accepts frame as reference but not as smart pointer
---
iocore/net/P_QUICNetVConnection.h | 2 +-
iocore/net/QUICNetVConnection.cc | 12 +++---
iocore/net/quic/Mock.h | 8 ++--
iocore/net/quic/QUICFrameDispatcher.cc | 2 +-
iocore/net/quic/QUICFrameHandler.h | 4 +-
iocore/net/quic/QUICHandshake.cc | 12 +++---
iocore/net/quic/QUICHandshake.h | 2 +-
iocore/net/quic/QUICLossDetector.cc | 24 +++++------
iocore/net/quic/QUICLossDetector.h | 4 +-
iocore/net/quic/QUICPathValidator.cc | 16 ++++----
iocore/net/quic/QUICPathValidator.h | 6 +--
iocore/net/quic/QUICStreamManager.cc | 56 +++++++++++++-------------
iocore/net/quic/QUICStreamManager.h | 14 +++----
iocore/net/quic/test/test_QUICLossDetector.cc | 8 ++--
iocore/net/quic/test/test_QUICStreamManager.cc | 24 +++++------
15 files changed, 97 insertions(+), 97 deletions(-)
diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index b2efbdf..ca02b19 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -214,7 +214,7 @@ public:
// QUICConnection (QUICFrameHandler)
std::vector<QUICFrameType> interests() override;
- QUICErrorUPtr handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame) override;
+ QUICErrorUPtr handle_frame(QUICEncryptionLevel level, const QUICFrame &frame) override;
// QUICConnection (QUICFrameGenerator)
// bool will_generate_frame(QUICEncryptionLevel level);
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index a44f136..f943c06 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -450,13 +450,13 @@ QUICNetVConnection::interests()
}
QUICErrorUPtr
-QUICNetVConnection::handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame)
+QUICNetVConnection::handle_frame(QUICEncryptionLevel level, const QUICFrame &frame)
{
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
- switch (frame->type()) {
+ switch (frame.type()) {
case QUICFrameType::MAX_DATA:
- this->_remote_flow_controller->forward_limit(std::static_pointer_cast<const QUICMaxDataFrame>(frame)->maximum_data());
+ this->_remote_flow_controller->forward_limit(static_cast<const QUICMaxDataFrame &>(frame).maximum_data());
QUICFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller->current_offset(),
this->_remote_flow_controller->current_limit());
this->_schedule_packet_write_ready();
@@ -475,14 +475,16 @@ QUICNetVConnection::handle_frame(QUICEncryptionLevel level, std::shared_ptr<cons
return error;
}
+ // FIXME ConnectionCloseFrame is cast to ApplicationCloseFrame
+
// 7.9.1. Closing and Draining Connection States
// An endpoint MAY transition from the closing period to the draining period if it can confirm that its peer is also closing or
// draining. Receiving a closing frame is sufficient confirmation, as is receiving a stateless reset.
this->_switch_to_draining_state(QUICConnectionErrorUPtr(
- new QUICConnectionError(std::static_pointer_cast<const QUICApplicationCloseFrame>(frame)->error_code())));
+ new QUICConnectionError(static_cast<const QUICApplicationCloseFrame&>(frame).error_code())));
break;
default:
- QUICConDebug("Unexpected frame type: %02x", static_cast<unsigned int>(frame->type()));
+ QUICConDebug("Unexpected frame type: %02x", static_cast<unsigned int>(frame.type()));
ink_assert(false);
break;
}
diff --git a/iocore/net/quic/Mock.h b/iocore/net/quic/Mock.h
index df68c42..15bd188 100644
--- a/iocore/net/quic/Mock.h
+++ b/iocore/net/quic/Mock.h
@@ -37,9 +37,9 @@ public:
MockQUICStreamManager() : QUICStreamManager() {}
// Override
virtual QUICErrorUPtr
- handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> f) override
+ handle_frame(QUICEncryptionLevel level, const QUICFrame &f) override
{
- ++_frameCount[static_cast<int>(f->type())];
+ ++_frameCount[static_cast<int>(f.type())];
++_totalFrameCount;
return QUICErrorUPtr(new QUICNoError());
@@ -198,9 +198,9 @@ public:
}
QUICErrorUPtr
- handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> f) override
+ handle_frame(QUICEncryptionLevel level, const QUICFrame &f) override
{
- ++_frameCount[static_cast<int>(f->type())];
+ ++_frameCount[static_cast<int>(f.type())];
++_totalFrameCount;
return QUICErrorUPtr(new QUICNoError());
diff --git a/iocore/net/quic/QUICFrameDispatcher.cc b/iocore/net/quic/QUICFrameDispatcher.cc
index afb90dd..3d5c876 100644
--- a/iocore/net/quic/QUICFrameDispatcher.cc
+++ b/iocore/net/quic/QUICFrameDispatcher.cc
@@ -69,7 +69,7 @@ QUICFrameDispatcher::receive_frames(QUICEncryptionLevel level, const uint8_t *pa
std::vector<QUICFrameHandler *> handlers = this->_handlers[static_cast<uint8_t>(type)];
for (auto h : handlers) {
- error = h->handle_frame(level, frame);
+ error = h->handle_frame(level, *frame.get());
// TODO: is there any case to continue this loop even if error?
if (error->cls != QUICErrorClass::NONE) {
return error;
diff --git a/iocore/net/quic/QUICFrameHandler.h b/iocore/net/quic/QUICFrameHandler.h
index 2384d60..0057977 100644
--- a/iocore/net/quic/QUICFrameHandler.h
+++ b/iocore/net/quic/QUICFrameHandler.h
@@ -30,6 +30,6 @@ class QUICFrameHandler
{
public:
virtual ~QUICFrameHandler(){};
- virtual std::vector<QUICFrameType> interests() = 0;
- virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame) = 0;
+ virtual std::vector<QUICFrameType> interests() = 0;
+ virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, const QUICFrame &frame) = 0;
};
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index 637b8cc..17d1144 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -337,18 +337,16 @@ QUICHandshake::interests()
}
QUICErrorUPtr
-QUICHandshake::handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame)
+QUICHandshake::handle_frame(QUICEncryptionLevel level, const QUICFrame &frame)
{
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
- switch (frame->type()) {
- case QUICFrameType::CRYPTO: {
- QUICCryptoFrameSPtr crypto_frame = std::static_pointer_cast<const QUICCryptoFrame>(frame);
- error = this->_crypto_streams[static_cast<int>(level)].recv(*crypto_frame);
+ switch (frame.type()) {
+ case QUICFrameType::CRYPTO:
+ error = this->_crypto_streams[static_cast<int>(level)].recv(static_cast<const QUICCryptoFrame &>(frame));
break;
- }
default:
- QUICHSDebug("Unexpected frame type: %02x", static_cast<unsigned int>(frame->type()));
+ QUICHSDebug("Unexpected frame type: %02x", static_cast<unsigned int>(frame.type()));
ink_assert(false);
break;
}
diff --git a/iocore/net/quic/QUICHandshake.h b/iocore/net/quic/QUICHandshake.h
index 4d1ea43..eb79f4a 100644
--- a/iocore/net/quic/QUICHandshake.h
+++ b/iocore/net/quic/QUICHandshake.h
@@ -47,7 +47,7 @@ public:
// QUICFrameHandler
virtual std::vector<QUICFrameType> interests() override;
- virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame) override;
+ virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, const QUICFrame &frame) override;
// QUICFrameGenerator
bool will_generate_frame(QUICEncryptionLevel level) override;
diff --git a/iocore/net/quic/QUICLossDetector.cc b/iocore/net/quic/QUICLossDetector.cc
index 548ee9b..a316dd7 100644
--- a/iocore/net/quic/QUICLossDetector.cc
+++ b/iocore/net/quic/QUICLossDetector.cc
@@ -106,7 +106,7 @@ QUICLossDetector::interests()
}
QUICErrorUPtr
-QUICLossDetector::handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame)
+QUICLossDetector::handle_frame(QUICEncryptionLevel level, const QUICFrame &frame)
{
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
@@ -114,13 +114,13 @@ QUICLossDetector::handle_frame(QUICEncryptionLevel level, std::shared_ptr<const
return error;
}
- switch (frame->type()) {
+ switch (frame.type()) {
case QUICFrameType::ACK:
this->_smoothed_rtt = this->_rtt_measure->smoothed_rtt();
- this->_on_ack_received(std::dynamic_pointer_cast<const QUICAckFrame>(frame));
+ this->_on_ack_received(static_cast<const QUICAckFrame &>(frame));
break;
default:
- QUICLDDebug("Unexpected frame type: %02x", static_cast<unsigned int>(frame->type()));
+ QUICLDDebug("Unexpected frame type: %02x", static_cast<unsigned int>(frame.type()));
ink_assert(false);
break;
}
@@ -209,28 +209,28 @@ QUICLossDetector::_on_packet_sent(QUICPacketNumber packet_number, bool is_ack_on
}
void
-QUICLossDetector::_on_ack_received(const std::shared_ptr<const QUICAckFrame> &ack_frame)
+QUICLossDetector::_on_ack_received(const QUICAckFrame &ack_frame)
{
SCOPED_MUTEX_LOCK(transmitter_lock, this->_transmitter->get_packet_transmitter_mutex().get(), this_ethread());
SCOPED_MUTEX_LOCK(lock, this->_loss_detection_mutex, this_ethread());
- this->_largest_acked_packet = ack_frame->largest_acknowledged();
+ this->_largest_acked_packet = ack_frame.largest_acknowledged();
// If the largest acked is newly acked, update the RTT.
- auto pi = this->_sent_packets.find(ack_frame->largest_acknowledged());
+ auto pi = this->_sent_packets.find(ack_frame.largest_acknowledged());
if (pi != this->_sent_packets.end()) {
this->_latest_rtt = Thread::get_hrtime() - pi->second->time;
- // _latest_rtt is nanosecond but ack_frame->ack_delay is microsecond and scaled
+ // _latest_rtt is nanosecond but ack_frame.ack_delay is microsecond and scaled
// FIXME ack delay exponent has to be read from transport parameters
uint8_t ack_delay_exponent = 3;
- ink_hrtime delay = HRTIME_USECONDS(ack_frame->ack_delay() << ack_delay_exponent);
- this->_update_rtt(this->_latest_rtt, delay, ack_frame->largest_acknowledged());
+ ink_hrtime delay = HRTIME_USECONDS(ack_frame.ack_delay() << ack_delay_exponent);
+ this->_update_rtt(this->_latest_rtt, delay, ack_frame.largest_acknowledged());
}
QUICLDVDebug("Unacked packets %lu (retransmittable %u, includes %u handshake packets)", this->_sent_packets.size(),
this->_retransmittable_outstanding.load(), this->_handshake_outstanding.load());
// Find all newly acked packets.
- for (auto &&range : this->_determine_newly_acked_packets(*ack_frame)) {
+ for (auto &&range : this->_determine_newly_acked_packets(ack_frame)) {
for (auto ite = this->_sent_packets.begin(); ite != this->_sent_packets.end(); /* no increment here*/) {
auto tmp_ite = ite;
tmp_ite++;
@@ -244,7 +244,7 @@ QUICLossDetector::_on_ack_received(const std::shared_ptr<const QUICAckFrame> &ac
QUICLDVDebug("Unacked packets %lu (retransmittable %u, includes %u handshake packets)", this->_sent_packets.size(),
this->_retransmittable_outstanding.load(), this->_handshake_outstanding.load());
- this->_detect_lost_packets(ack_frame->largest_acknowledged());
+ this->_detect_lost_packets(ack_frame.largest_acknowledged());
QUICLDDebug("Unacked packets %lu (retransmittable %u, includes %u handshake packets)", this->_sent_packets.size(),
this->_retransmittable_outstanding.load(), this->_handshake_outstanding.load());
diff --git a/iocore/net/quic/QUICLossDetector.h b/iocore/net/quic/QUICLossDetector.h
index 4bb26ec..4adfbee 100644
--- a/iocore/net/quic/QUICLossDetector.h
+++ b/iocore/net/quic/QUICLossDetector.h
@@ -116,7 +116,7 @@ public:
int event_handler(int event, Event *edata);
std::vector<QUICFrameType> interests() override;
- virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame>) override;
+ virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, const QUICFrame &frame) override;
void on_packet_sent(QUICPacketUPtr packet);
QUICPacketNumber largest_acked_packet_number();
void reset();
@@ -175,7 +175,7 @@ private:
void _on_packet_sent(QUICPacketNumber packet_number, bool is_ack_only, bool is_handshake, size_t sent_bytes,
QUICPacketUPtr packet);
- void _on_ack_received(const std::shared_ptr<const QUICAckFrame> &ack_frame);
+ void _on_ack_received(const QUICAckFrame &ack_frame);
void _on_packet_acked(const PacketInfo &acked_packet);
void _update_rtt(ink_hrtime latest_rtt, ink_hrtime ack_delay, QUICPacketNumber largest_acked);
void _detect_lost_packets(QUICPacketNumber largest_acked);
diff --git a/iocore/net/quic/QUICPathValidator.cc b/iocore/net/quic/QUICPathValidator.cc
index bdc6cc6..2a54e4f 100644
--- a/iocore/net/quic/QUICPathValidator.cc
+++ b/iocore/net/quic/QUICPathValidator.cc
@@ -51,19 +51,19 @@ QUICPathValidator::_generate_challenge()
}
void
-QUICPathValidator::_generate_response(std::shared_ptr<const QUICPathChallengeFrame> frame)
+QUICPathValidator::_generate_response(const QUICPathChallengeFrame &frame)
{
- memcpy(this->_incoming_challenge, frame->data(), QUICPathChallengeFrame::DATA_LEN);
+ memcpy(this->_incoming_challenge, frame.data(), QUICPathChallengeFrame::DATA_LEN);
this->_has_outgoing_response = true;
}
QUICErrorUPtr
-QUICPathValidator::_validate_response(std::shared_ptr<const QUICPathResponseFrame> frame)
+QUICPathValidator::_validate_response(const QUICPathResponseFrame &frame)
{
QUICErrorUPtr error = QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::UNSOLICITED_PATH_RESPONSE));
for (int i = 0; i < 3; ++i) {
- if (memcmp(this->_outgoing_challenge + (QUICPathChallengeFrame::DATA_LEN * i), frame->data(),
+ if (memcmp(this->_outgoing_challenge + (QUICPathChallengeFrame::DATA_LEN * i), frame.data(),
QUICPathChallengeFrame::DATA_LEN) == 0) {
this->_state = ValidationState::VALIDATED;
this->_has_outgoing_challenge = 0;
@@ -85,16 +85,16 @@ QUICPathValidator::interests()
}
QUICErrorUPtr
-QUICPathValidator::handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame)
+QUICPathValidator::handle_frame(QUICEncryptionLevel level, const QUICFrame &frame)
{
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
- switch (frame->type()) {
+ switch (frame.type()) {
case QUICFrameType::PATH_CHALLENGE:
- this->_generate_response(std::static_pointer_cast<const QUICPathChallengeFrame>(frame));
+ this->_generate_response(static_cast<const QUICPathChallengeFrame &>(frame));
break;
case QUICFrameType::PATH_RESPONSE:
- error = this->_validate_response(std::static_pointer_cast<const QUICPathResponseFrame>(frame));
+ error = this->_validate_response(static_cast<const QUICPathResponseFrame &>(frame));
break;
default:
ink_assert(!"Can't happen");
diff --git a/iocore/net/quic/QUICPathValidator.h b/iocore/net/quic/QUICPathValidator.h
index 30d10fb..d13723f 100644
--- a/iocore/net/quic/QUICPathValidator.h
+++ b/iocore/net/quic/QUICPathValidator.h
@@ -37,7 +37,7 @@ public:
// QUICFrameHandler
std::vector<QUICFrameType> interests() override;
- QUICErrorUPtr handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame) override;
+ QUICErrorUPtr handle_frame(QUICEncryptionLevel level, const QUICFrame &frame) override;
// QUICFrameGeneratro
bool will_generate_frame(QUICEncryptionLevel level) override;
@@ -56,6 +56,6 @@ private:
uint8_t _outgoing_challenge[QUICPathChallengeFrame::DATA_LEN * 3];
void _generate_challenge();
- void _generate_response(std::shared_ptr<const QUICPathChallengeFrame> frame);
- QUICErrorUPtr _validate_response(std::shared_ptr<const QUICPathResponseFrame> frame);
+ void _generate_response(const QUICPathChallengeFrame &frame);
+ QUICErrorUPtr _validate_response(const QUICPathResponseFrame &frame);
};
diff --git a/iocore/net/quic/QUICStreamManager.cc b/iocore/net/quic/QUICStreamManager.cc
index f63715e..fd0690b 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -136,32 +136,32 @@ QUICStreamManager::reset_stream(QUICStreamId stream_id, QUICStreamErrorUPtr erro
}
QUICErrorUPtr
-QUICStreamManager::handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame> frame)
+QUICStreamManager::handle_frame(QUICEncryptionLevel level, const QUICFrame &frame)
{
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
- switch (frame->type()) {
+ switch (frame.type()) {
case QUICFrameType::MAX_STREAM_DATA:
- error = this->_handle_frame(std::static_pointer_cast<const QUICMaxStreamDataFrame>(frame));
+ error = this->_handle_frame(static_cast<const QUICMaxStreamDataFrame &>(frame));
break;
case QUICFrameType::STREAM_BLOCKED:
// STREAM_BLOCKED frame is for debugging. Just propagate to streams
- error = this->_handle_frame(std::static_pointer_cast<const QUICStreamBlockedFrame>(frame));
+ error = this->_handle_frame(static_cast<const QUICStreamBlockedFrame &>(frame));
break;
case QUICFrameType::STREAM:
- error = this->_handle_frame(std::static_pointer_cast<const QUICStreamFrame>(frame));
+ error = this->_handle_frame(static_cast<const QUICStreamFrame &>(frame));
break;
case QUICFrameType::STOP_SENDING:
- error = this->_handle_frame(std::static_pointer_cast<const QUICStopSendingFrame>(frame));
+ error = this->_handle_frame(static_cast<const QUICStopSendingFrame &>(frame));
break;
case QUICFrameType::RST_STREAM:
- error = this->_handle_frame(std::static_pointer_cast<const QUICRstStreamFrame>(frame));
+ error = this->_handle_frame(static_cast<const QUICRstStreamFrame &>(frame));
break;
case QUICFrameType::MAX_STREAM_ID:
- error = this->_handle_frame(std::static_pointer_cast<const QUICMaxStreamIdFrame>(frame));
+ error = this->_handle_frame(static_cast<const QUICMaxStreamIdFrame &>(frame));
break;
default:
- Debug(tag, "Unexpected frame type: %02x", static_cast<unsigned int>(frame->type()));
+ Debug(tag, "Unexpected frame type: %02x", static_cast<unsigned int>(frame.type()));
ink_assert(false);
break;
}
@@ -170,49 +170,49 @@ QUICStreamManager::handle_frame(QUICEncryptionLevel level, std::shared_ptr<const
}
QUICErrorUPtr
-QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICMaxStreamDataFrame> &frame)
+QUICStreamManager::_handle_frame(const QUICMaxStreamDataFrame &frame)
{
- QUICStream *stream = this->_find_or_create_stream(frame->stream_id());
+ QUICStream *stream = this->_find_or_create_stream(frame.stream_id());
if (stream) {
- return stream->recv(*frame);
+ return stream->recv(frame);
} else {
return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::STREAM_ID_ERROR));
}
}
QUICErrorUPtr
-QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICStreamBlockedFrame> &frame)
+QUICStreamManager::_handle_frame(const QUICStreamBlockedFrame &frame)
{
- QUICStream *stream = this->_find_or_create_stream(frame->stream_id());
+ QUICStream *stream = this->_find_or_create_stream(frame.stream_id());
if (stream) {
- return stream->recv(*frame);
+ return stream->recv(frame);
} else {
return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::STREAM_ID_ERROR));
}
}
QUICErrorUPtr
-QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICStreamFrame> &frame)
+QUICStreamManager::_handle_frame(const QUICStreamFrame &frame)
{
- QUICStream *stream = this->_find_or_create_stream(frame->stream_id());
+ QUICStream *stream = this->_find_or_create_stream(frame.stream_id());
if (!stream) {
return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::STREAM_ID_ERROR));
}
- QUICApplication *application = this->_app_map->get(frame->stream_id());
+ QUICApplication *application = this->_app_map->get(frame.stream_id());
if (application && !application->is_stream_set(stream)) {
application->set_stream(stream);
}
- QUICErrorUPtr error = stream->recv(*frame);
+ QUICErrorUPtr error = stream->recv(frame);
return error;
}
QUICErrorUPtr
-QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICRstStreamFrame> &frame)
+QUICStreamManager::_handle_frame(const QUICRstStreamFrame &frame)
{
- QUICStream *stream = this->_find_or_create_stream(frame->stream_id());
+ QUICStream *stream = this->_find_or_create_stream(frame.stream_id());
if (stream) {
// TODO Reset the stream
return QUICErrorUPtr(new QUICNoError());
@@ -222,24 +222,24 @@ QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICRstStreamFrame>
}
QUICErrorUPtr
-QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICStopSendingFrame> &frame)
+QUICStreamManager::_handle_frame(const QUICStopSendingFrame &frame)
{
- QUICStream *stream = this->_find_or_create_stream(frame->stream_id());
+ QUICStream *stream = this->_find_or_create_stream(frame.stream_id());
if (stream) {
- return stream->recv(*frame);
+ return stream->recv(frame);
} else {
return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::STREAM_ID_ERROR));
}
}
QUICErrorUPtr
-QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICMaxStreamIdFrame> &frame)
+QUICStreamManager::_handle_frame(const QUICMaxStreamIdFrame &frame)
{
- QUICStreamType type = QUICTypeUtil::detect_stream_type(frame->maximum_stream_id());
+ QUICStreamType type = QUICTypeUtil::detect_stream_type(frame.maximum_stream_id());
if (type == QUICStreamType::SERVER_BIDI || type == QUICStreamType::CLIENT_BIDI) {
- this->_remote_maximum_stream_id_bidi = frame->maximum_stream_id();
+ this->_remote_maximum_stream_id_bidi = frame.maximum_stream_id();
} else {
- this->_remote_maximum_stream_id_uni = frame->maximum_stream_id();
+ this->_remote_maximum_stream_id_uni = frame.maximum_stream_id();
}
return QUICErrorUPtr(new QUICNoError());
}
diff --git a/iocore/net/quic/QUICStreamManager.h b/iocore/net/quic/QUICStreamManager.h
index 49bf9b3..be5c016 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -59,7 +59,7 @@ public:
// QUICFrameHandler
virtual std::vector<QUICFrameType> interests() override;
- virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, std::shared_ptr<const QUICFrame>) override;
+ virtual QUICErrorUPtr handle_frame(QUICEncryptionLevel level, const QUICFrame &frame) override;
// QUICFrameGenerator
bool will_generate_frame(QUICEncryptionLevel level) override;
@@ -68,12 +68,12 @@ public:
private:
QUICStream *_find_stream(QUICStreamId id);
QUICStream *_find_or_create_stream(QUICStreamId stream_id);
- QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICStreamFrame> &);
- QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICRstStreamFrame> &);
- QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICStopSendingFrame> &);
- QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICMaxStreamDataFrame> &);
- QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICStreamBlockedFrame> &);
- QUICErrorUPtr _handle_frame(const std::shared_ptr<const QUICMaxStreamIdFrame> &);
+ QUICErrorUPtr _handle_frame(const QUICStreamFrame &frame);
+ QUICErrorUPtr _handle_frame(const QUICRstStreamFrame &frame);
+ QUICErrorUPtr _handle_frame(const QUICStopSendingFrame &frame);
+ QUICErrorUPtr _handle_frame(const QUICMaxStreamDataFrame &frame);
+ QUICErrorUPtr _handle_frame(const QUICStreamBlockedFrame &frame);
+ QUICErrorUPtr _handle_frame(const QUICMaxStreamIdFrame &frame);
std::vector<QUICEncryptionLevel>
_encryption_level_filter() override
{
diff --git a/iocore/net/quic/test/test_QUICLossDetector.cc b/iocore/net/quic/test/test_QUICLossDetector.cc
index 628a96d..a414872 100644
--- a/iocore/net/quic/test/test_QUICLossDetector.cc
+++ b/iocore/net/quic/test/test_QUICLossDetector.cc
@@ -69,8 +69,8 @@ TEST_CASE("QUICLossDetector_Loss", "[quic]")
CHECK(tx->retransmitted.size() > 0);
// Receive ACK
- std::shared_ptr<QUICAckFrame> frame = std::make_shared<QUICAckFrame>(0x01, 20, 0);
- frame->ack_block_section()->add_ack_block({0, 1ULL});
+ QUICAckFrame frame(0x01, 20, 0);
+ frame.ack_block_section()->add_ack_block({0, 1ULL});
detector.handle_frame(QUICEncryptionLevel::INITIAL, frame);
ink_hrtime_sleep(HRTIME_MSECONDS(1500));
int retransmit_count = tx->retransmitted.size();
@@ -144,7 +144,7 @@ TEST_CASE("QUICLossDetector_Loss", "[quic]")
ink_hrtime_sleep(HRTIME_MSECONDS(1000));
std::shared_ptr<QUICFrame> x = afc->generate_frame(QUICEncryptionLevel::INITIAL, 2048, 2048);
frame = std::dynamic_pointer_cast<QUICAckFrame>(x);
- detector.handle_frame(QUICEncryptionLevel::INITIAL, frame);
+ detector.handle_frame(QUICEncryptionLevel::INITIAL, *frame.get());
ink_hrtime_sleep(HRTIME_MSECONDS(5000));
CHECK(cc->lost_packets.size() == 3);
@@ -175,7 +175,7 @@ TEST_CASE("QUICLossDetector_HugeGap", "[quic]")
auto t1 = Thread::get_hrtime();
std::shared_ptr<QUICAckFrame> ack = QUICFrameFactory::create_ack_frame(100000000, 100, 10000000);
ack->ack_block_section()->add_ack_block({20000000, 30000000});
- detector.handle_frame(QUICEncryptionLevel::INITIAL, ack);
+ detector.handle_frame(QUICEncryptionLevel::INITIAL, *ack.get());
auto t2 = Thread::get_hrtime();
CHECK(t2 - t1 < HRTIME_MSECONDS(100));
}
diff --git a/iocore/net/quic/test/test_QUICStreamManager.cc b/iocore/net/quic/test/test_QUICStreamManager.cc
index 5f21f27..cf463a5 100644
--- a/iocore/net/quic/test/test_QUICStreamManager.cc
+++ b/iocore/net/quic/test/test_QUICStreamManager.cc
@@ -48,31 +48,31 @@ TEST_CASE("QUICStreamManager_NewStream", "[quic]")
std::shared_ptr<QUICFrame> stream_frame_1 =
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("abc"), 3, 1, 0);
CHECK(sm.stream_count() == 0);
- sm.handle_frame(level, stream_frame_0);
+ sm.handle_frame(level, *stream_frame_0);
CHECK(sm.stream_count() == 1);
- sm.handle_frame(level, stream_frame_1);
+ sm.handle_frame(level, *stream_frame_1);
CHECK(sm.stream_count() == 2);
// RST_STREAM frames create new streams
std::shared_ptr<QUICFrame> rst_stream_frame =
QUICFrameFactory::create_rst_stream_frame(2, static_cast<QUICAppErrorCode>(0x01), 0);
- sm.handle_frame(level, rst_stream_frame);
+ sm.handle_frame(level, *rst_stream_frame);
CHECK(sm.stream_count() == 3);
// MAX_STREAM_DATA frames create new streams
std::shared_ptr<QUICFrame> max_stream_data_frame = QUICFrameFactory::create_max_stream_data_frame(3, 0);
- sm.handle_frame(level, max_stream_data_frame);
+ sm.handle_frame(level, *max_stream_data_frame);
CHECK(sm.stream_count() == 4);
// STREAM_BLOCKED frames create new streams
std::shared_ptr<QUICFrame> stream_blocked_frame = QUICFrameFactory::create_stream_blocked_frame(4, 0);
- sm.handle_frame(level, stream_blocked_frame);
+ sm.handle_frame(level, *stream_blocked_frame);
CHECK(sm.stream_count() == 5);
// Set local maximum stream id
sm.set_max_stream_id(5);
std::shared_ptr<QUICFrame> stream_blocked_frame_x = QUICFrameFactory::create_stream_blocked_frame(8, 0);
- sm.handle_frame(level, stream_blocked_frame_x);
+ sm.handle_frame(level, *stream_blocked_frame_x);
CHECK(sm.stream_count() == 5);
}
@@ -93,7 +93,7 @@ TEST_CASE("QUICStreamManager_first_initial_map", "[quic]")
std::shared_ptr<QUICFrame> stream_frame_0 =
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("abc"), 3, 0, 7);
- sm.handle_frame(level, stream_frame_0);
+ sm.handle_frame(level, *stream_frame_0);
CHECK("succeed");
}
@@ -115,14 +115,14 @@ TEST_CASE("QUICStreamManager_total_offset_received", "[quic]")
// Create a stream with STREAM_BLOCKED (== noop)
std::shared_ptr<QUICFrame> stream_blocked_frame_0 = QUICFrameFactory::create_stream_blocked_frame(0, 0);
std::shared_ptr<QUICFrame> stream_blocked_frame_1 = QUICFrameFactory::create_stream_blocked_frame(1, 0);
- sm.handle_frame(level, stream_blocked_frame_0);
- sm.handle_frame(level, stream_blocked_frame_1);
+ sm.handle_frame(level, *stream_blocked_frame_0);
+ sm.handle_frame(level, *stream_blocked_frame_1);
CHECK(sm.stream_count() == 2);
CHECK(sm.total_offset_received() == 0);
// total_offset should be a integer in unit of 1024 octets
std::shared_ptr<QUICFrame> stream_frame_1 = QUICFrameFactory::create_stream_frame(data, 1024, 1, 0);
- sm.handle_frame(level, stream_frame_1);
+ sm.handle_frame(level, *stream_frame_1);
CHECK(sm.total_offset_received() == 1024);
}
@@ -146,8 +146,8 @@ TEST_CASE("QUICStreamManager_total_offset_sent", "[quic]")
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("abc"), 3, 0, 0);
std::shared_ptr<QUICFrame> stream_frame_1_r =
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("abc"), 3, 1, 0);
- sm.handle_frame(level, stream_frame_0_r);
- sm.handle_frame(level, stream_frame_1_r);
+ sm.handle_frame(level, *stream_frame_0_r);
+ sm.handle_frame(level, *stream_frame_1_r);
CHECK(sm.stream_count() == 2);
CHECK(sm.total_offset_sent() == 0);