Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/quic/node_quic_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2000,8 +2000,8 @@ void QuicSession::RemoveFromSocket() {
}

Debug(this, "Removed from the QuicSocket.");
socket_->RemoveSession(scid_, remote_address_);
socket_.reset();
BaseObjectPtr<QuicSocket> socket = std::move(socket_);
socket->RemoveSession(scid_, remote_address_);
}

// Removes the given stream from the QuicSession. All streams must
Expand Down
4 changes: 2 additions & 2 deletions src/quic/node_quic_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,8 @@ class QuicSession : public AsyncWrap,
uint64_t{NGTCP2_NO_ERROR}
};
ConnectionPointer connection_;
SocketAddress local_address_;
SocketAddress remote_address_;
SocketAddress local_address_{};
SocketAddress remote_address_{};
uint32_t flags_ = 0;
size_t max_pktlen_ = 0;
size_t current_ngtcp2_memory_ = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/quic/node_quic_socket-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ void QuicSocket::ReceiveStop() {
void QuicSocket::RemoveSession(
const QuicCID& cid,
const SocketAddress& addr) {
sessions_.erase(cid);
DecrementSocketAddressCounter(addr);
sessions_.erase(cid);
}

void QuicSocket::ReportSendError(int error) {
Expand Down
2 changes: 1 addition & 1 deletion src/quic/node_quic_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ void QuicSocket::ImmediateConnectionClose(
const QuicCID& dcid,
const SocketAddress& local_addr,
const SocketAddress& remote_addr,
int32_t reason) {
int64_t reason) {
Debug(this, "Sending stateless connection close to %s", scid);
auto packet = QuicPacket::Create("immediate connection close");
ssize_t nwrite = ngtcp2_crypto_write_connection_close(
Expand Down
2 changes: 1 addition & 1 deletion src/quic/node_quic_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class QuicSocket : public AsyncWrap,
const QuicCID& dcid,
const SocketAddress& local_addr,
const SocketAddress& remote_addr,
int32_t reason = NGTCP2_INVALID_TOKEN);
int64_t reason = NGTCP2_INVALID_TOKEN);

private:
static void OnAlloc(
Expand Down
24 changes: 12 additions & 12 deletions src/quic/node_quic_util-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ size_t QuicCID::Hash::operator()(const QuicCID& token) const {
return hash;
}

bool QuicCID::Compare::operator()(
const QuicCID& lcid,
const QuicCID& rcid) const {
return lcid->datalen != rcid->datalen ?
false : memcmp(lcid->data, rcid->data, lcid->datalen) == 0;
bool QuicCID::operator==(const QuicCID& other) const {
return memcmp(cid(), other.cid(), sizeof(ngtcp2_cid)) == 0;
}

bool QuicCID::operator!=(const QuicCID& other) const {
return !(*this == other);
}

std::string QuicCID::ToString() const {
Expand Down Expand Up @@ -310,13 +311,12 @@ size_t StatelessResetToken::Hash::operator()(
return hash;
}

bool StatelessResetToken::Compare::operator()(
const StatelessResetToken& ltoken,
const StatelessResetToken& rtoken) const {
return memcmp(
ltoken.token_,
rtoken.token_,
NGTCP2_STATELESS_RESET_TOKENLEN) == 0;
bool StatelessResetToken::operator==(const StatelessResetToken& other) const {
return memcmp(data(), other.data(), NGTCP2_STATELESS_RESET_TOKENLEN) == 0;
}

bool StatelessResetToken::operator!=(const StatelessResetToken& other) const {
return !(*this == other);
}

template <typename T>
Expand Down
17 changes: 6 additions & 11 deletions src/quic/node_quic_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,8 @@ class QuicCID : public MemoryRetainer {
inline size_t operator()(const QuicCID& cid) const;
};

struct Compare {
inline bool operator()(const QuicCID& lcid, const QuicCID& rcid) const;
};
inline bool operator==(const QuicCID& other) const;
inline bool operator!=(const QuicCID& other) const;

inline std::string ToString() const;

Expand Down Expand Up @@ -303,7 +302,7 @@ class QuicCID : public MemoryRetainer {
SET_SELF_SIZE(QuicCID)

template <typename T>
using Map = std::unordered_map<QuicCID, T, QuicCID::Hash, QuicCID::Compare>;
using Map = std::unordered_map<QuicCID, T, QuicCID::Hash>;

private:
ngtcp2_cid cid_{};
Expand Down Expand Up @@ -362,11 +361,8 @@ class StatelessResetToken : public MemoryRetainer {
inline size_t operator()(const StatelessResetToken& token) const;
};

struct Compare {
inline bool operator()(
const StatelessResetToken& ltoken,
const StatelessResetToken& rtoken) const;
};
inline bool operator==(const StatelessResetToken& other) const;
inline bool operator!=(const StatelessResetToken& other) const;

SET_NO_MEMORY_INFO()
SET_MEMORY_INFO_NAME(StatelessResetToken)
Expand All @@ -377,8 +373,7 @@ class StatelessResetToken : public MemoryRetainer {
std::unordered_map<
StatelessResetToken,
BaseObjectPtr<T>,
StatelessResetToken::Hash,
StatelessResetToken::Compare>;
StatelessResetToken::Hash>;

private:
uint8_t buf_[NGTCP2_STATELESS_RESET_TOKENLEN]{};
Expand Down