Copilot commented on code in PR #13292:
URL: https://github.com/apache/trafficserver/pull/13292#discussion_r3431748830
##########
include/iocore/net/ProxyProtocol.h:
##########
@@ -82,6 +82,25 @@ class ProxyProtocol
other.tlv.clear();
}
~ProxyProtocol() = default;
+
+ /** Release owned heap and reset to the default-constructed state.
+ *
+ * Swap rather than clear() the containers: clear() retains capacity, which
would be abandoned
+ * (leaked) when the slot is reused, since the NetVConnection allocators are
Destruct_on_free=false
+ * and so never run ~ProxyProtocol.
+ */
+ void
+ reset()
+ {
+ std::string{}.swap(additional_data);
+ std::unordered_map<uint8_t, std::string_view>{}.swap(tlv);
+ version = ProxyProtocolVersion::UNDEFINED;
+ ip_family = AF_UNSPEC;
+ type = 0;
+ src_addr = {};
+ dst_addr = {};
+ }
Review Comment:
`ProxyProtocol::reset()` is new behavior but there’s no unit test coverage
for it. Since `src/iocore/net/unit_tests/test_ProxyProtocol.cc` already exists,
please add a small test that populates `pp_info` (including TLVs), calls
`reset()`, and asserts fields are back to the default state (e.g.,
`version==UNDEFINED`, `ip_family==AF_UNSPEC`, `tlv.empty()`, and `get_tlv(...)`
returns nullopt). This helps prevent regressions where `reset()` stops fully
clearing state or stops releasing the backing `additional_data` storage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]