@@ -33,36 +33,23 @@ void WebTransportImpl::destroy() {
33
33
34
34
void WebTransportImpl::terminateSessionStreams (uint32_t errorCode,
35
35
const std::string& reason) {
36
- // These loops are dicey for possible erasure from callbacks
37
- for (auto ingressStreamIt = wtIngressStreams_.begin ();
38
- ingressStreamIt != wtIngressStreams_.end ();) {
39
- auto id = ingressStreamIt->first ;
40
- auto & stream = ingressStreamIt->second ;
41
- ingressStreamIt++;
36
+ auto wtIngressStreams = std::move (wtIngressStreams_);
37
+ for (auto & [id, stream] : wtIngressStreams) {
42
38
// Deliver an error to the application if needed
39
+ VLOG (4 ) << " aborting wt ingress id=" << id << " err=" << errorCode
40
+ << " ; open=" << int (stream.open ());
43
41
if (stream.open ()) {
44
- VLOG (4 ) << " aborting WT ingress id=" << id << " with error=" << errorCode;
45
42
stream.deliverReadError (WebTransport::Exception (errorCode, reason));
46
43
stopReadingWebTransportIngress (id, errorCode);
47
- } else {
48
- VLOG (4 ) << " WT ingress already complete for id=" << id;
49
44
}
50
45
}
51
- wtIngressStreams_.clear ();
52
- for (auto egressStreamIt = wtEgressStreams_.begin ();
53
- egressStreamIt != wtEgressStreams_.end ();) {
54
- auto id = egressStreamIt->first ;
55
- auto & stream = egressStreamIt->second ;
56
- egressStreamIt++;
46
+
47
+ auto wtEgressStreams = std::move (wtEgressStreams_);
48
+ for (auto & [id, stream] : wtEgressStreams) {
57
49
// Deliver an error to the application
58
50
stream.onStopSending (errorCode);
59
- // The handler may have run and reset this stream, removing it from
60
- // wtEgressStreams_, otherwise we have to reset it.
61
- if (wtEgressStreams_.find (id) != wtEgressStreams_.end ()) {
62
- resetWebTransportEgress (id, errorCode);
63
- }
51
+ resetWebTransportEgress (id, errorCode);
64
52
}
65
- wtEgressStreams_.clear ();
66
53
}
67
54
68
55
void WebTransportImpl::onMaxData (uint64_t maxData) noexcept {
0 commit comments