Coverage Report

Created: 2026-04-01 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/h2/src/proto/connection.rs
Line
Count
Source
1
use crate::codec::UserError;
2
use crate::frame::{Reason, StreamId};
3
use crate::{client, server};
4
5
use crate::frame::DEFAULT_INITIAL_WINDOW_SIZE;
6
use crate::proto::*;
7
8
use bytes::Bytes;
9
use futures_core::Stream;
10
use std::io;
11
use std::marker::PhantomData;
12
use std::pin::Pin;
13
use std::task::{Context, Poll};
14
use std::time::Duration;
15
use tokio::io::AsyncRead;
16
17
/// An H2 connection
18
#[derive(Debug)]
19
pub(crate) struct Connection<T, P, B: Buf = Bytes>
20
where
21
    P: Peer,
22
{
23
    /// Read / write frame values
24
    codec: Codec<T, Prioritized<B>>,
25
26
    inner: ConnectionInner<P, B>,
27
}
28
29
// Extracted part of `Connection` which does not depend on `T`. Reduces the amount of duplicated
30
// method instantiations.
31
#[derive(Debug)]
32
struct ConnectionInner<P, B: Buf = Bytes>
33
where
34
    P: Peer,
35
{
36
    /// Tracks the connection level state transitions.
37
    state: State,
38
39
    /// An error to report back once complete.
40
    ///
41
    /// This exists separately from State in order to support
42
    /// graceful shutdown.
43
    error: Option<frame::GoAway>,
44
45
    /// Pending GOAWAY frames to write.
46
    go_away: GoAway,
47
48
    /// Ping/pong handler
49
    ping_pong: PingPong,
50
51
    /// Connection settings
52
    settings: Settings,
53
54
    /// Stream state handler
55
    streams: Streams<B, P>,
56
57
    /// A `tracing` span tracking the lifetime of the connection.
58
    span: tracing::Span,
59
60
    /// Client or server
61
    _phantom: PhantomData<P>,
62
}
63
64
struct DynConnection<'a, B: Buf = Bytes> {
65
    state: &'a mut State,
66
67
    go_away: &'a mut GoAway,
68
69
    streams: DynStreams<'a, B>,
70
71
    error: &'a mut Option<frame::GoAway>,
72
73
    ping_pong: &'a mut PingPong,
74
}
75
76
#[derive(Debug, Clone)]
77
pub(crate) struct Config {
78
    pub next_stream_id: StreamId,
79
    pub initial_max_send_streams: usize,
80
    pub max_send_buffer_size: usize,
81
    pub reset_stream_duration: Duration,
82
    pub reset_stream_max: usize,
83
    pub remote_reset_stream_max: usize,
84
    pub local_error_reset_streams_max: Option<usize>,
85
    pub settings: frame::Settings,
86
}
87
88
#[derive(Debug)]
89
enum State {
90
    /// Currently open in a sane state
91
    Open,
92
93
    /// The codec must be flushed
94
    Closing(Reason, Initiator),
95
96
    /// In a closed state
97
    Closed(Reason, Initiator),
98
}
99
100
impl<T, P, B> Connection<T, P, B>
101
where
102
    T: AsyncRead + AsyncWrite + Unpin,
103
    P: Peer,
104
    B: Buf,
105
{
106
14.5k
    pub fn new(codec: Codec<T, Prioritized<B>>, config: Config) -> Connection<T, P, B> {
107
14.5k
        fn streams_config(config: &Config) -> streams::Config {
108
            streams::Config {
109
14.5k
                initial_max_send_streams: config.initial_max_send_streams,
110
14.5k
                local_max_buffer_size: config.max_send_buffer_size,
111
14.5k
                local_next_stream_id: config.next_stream_id,
112
14.5k
                local_push_enabled: config.settings.is_push_enabled().unwrap_or(true),
113
14.5k
                extended_connect_protocol_enabled: config
114
14.5k
                    .settings
115
14.5k
                    .is_extended_connect_protocol_enabled()
116
14.5k
                    .unwrap_or(false),
117
14.5k
                local_reset_duration: config.reset_stream_duration,
118
14.5k
                local_reset_max: config.reset_stream_max,
119
14.5k
                remote_reset_max: config.remote_reset_stream_max,
120
                remote_init_window_sz: DEFAULT_INITIAL_WINDOW_SIZE,
121
14.5k
                remote_max_initiated: config
122
14.5k
                    .settings
123
14.5k
                    .max_concurrent_streams()
124
14.5k
                    .map(|max| max as usize),
125
14.5k
                local_max_error_reset_streams: config.local_error_reset_streams_max,
126
            }
127
14.5k
        }
128
14.5k
        let streams = Streams::new(streams_config(&config));
129
14.5k
        let span = tracing::debug_span!(parent: None, "Connection", peer = %P::NAME);
130
14.5k
        span.follows_from(tracing::Span::current());
131
14.5k
        Connection {
132
14.5k
            codec,
133
14.5k
            inner: ConnectionInner {
134
14.5k
                state: State::Open,
135
14.5k
                error: None,
136
14.5k
                go_away: GoAway::new(),
137
14.5k
                ping_pong: PingPong::new(),
138
14.5k
                settings: Settings::new(config.settings),
139
14.5k
                streams,
140
14.5k
                span,
141
14.5k
                _phantom: PhantomData,
142
14.5k
            },
143
14.5k
        }
144
14.5k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::new
<h2::proto::connection::Connection<h2_support::mock::Mock, h2::client::Peer>>::new
Line
Count
Source
106
776
    pub fn new(codec: Codec<T, Prioritized<B>>, config: Config) -> Connection<T, P, B> {
107
        fn streams_config(config: &Config) -> streams::Config {
108
            streams::Config {
109
                initial_max_send_streams: config.initial_max_send_streams,
110
                local_max_buffer_size: config.max_send_buffer_size,
111
                local_next_stream_id: config.next_stream_id,
112
                local_push_enabled: config.settings.is_push_enabled().unwrap_or(true),
113
                extended_connect_protocol_enabled: config
114
                    .settings
115
                    .is_extended_connect_protocol_enabled()
116
                    .unwrap_or(false),
117
                local_reset_duration: config.reset_stream_duration,
118
                local_reset_max: config.reset_stream_max,
119
                remote_reset_max: config.remote_reset_stream_max,
120
                remote_init_window_sz: DEFAULT_INITIAL_WINDOW_SIZE,
121
                remote_max_initiated: config
122
                    .settings
123
                    .max_concurrent_streams()
124
                    .map(|max| max as usize),
125
                local_max_error_reset_streams: config.local_error_reset_streams_max,
126
            }
127
        }
128
776
        let streams = Streams::new(streams_config(&config));
129
776
        let span = tracing::debug_span!(parent: None, "Connection", peer = %P::NAME);
130
776
        span.follows_from(tracing::Span::current());
131
776
        Connection {
132
776
            codec,
133
776
            inner: ConnectionInner {
134
776
                state: State::Open,
135
776
                error: None,
136
776
                go_away: GoAway::new(),
137
776
                ping_pong: PingPong::new(),
138
776
                settings: Settings::new(config.settings),
139
776
                streams,
140
776
                span,
141
776
                _phantom: PhantomData,
142
776
            },
143
776
        }
144
776
    }
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::new
Line
Count
Source
106
13.7k
    pub fn new(codec: Codec<T, Prioritized<B>>, config: Config) -> Connection<T, P, B> {
107
        fn streams_config(config: &Config) -> streams::Config {
108
            streams::Config {
109
                initial_max_send_streams: config.initial_max_send_streams,
110
                local_max_buffer_size: config.max_send_buffer_size,
111
                local_next_stream_id: config.next_stream_id,
112
                local_push_enabled: config.settings.is_push_enabled().unwrap_or(true),
113
                extended_connect_protocol_enabled: config
114
                    .settings
115
                    .is_extended_connect_protocol_enabled()
116
                    .unwrap_or(false),
117
                local_reset_duration: config.reset_stream_duration,
118
                local_reset_max: config.reset_stream_max,
119
                remote_reset_max: config.remote_reset_stream_max,
120
                remote_init_window_sz: DEFAULT_INITIAL_WINDOW_SIZE,
121
                remote_max_initiated: config
122
                    .settings
123
                    .max_concurrent_streams()
124
                    .map(|max| max as usize),
125
                local_max_error_reset_streams: config.local_error_reset_streams_max,
126
            }
127
        }
128
13.7k
        let streams = Streams::new(streams_config(&config));
129
13.7k
        let span = tracing::debug_span!(parent: None, "Connection", peer = %P::NAME);
130
13.7k
        span.follows_from(tracing::Span::current());
131
13.7k
        Connection {
132
13.7k
            codec,
133
13.7k
            inner: ConnectionInner {
134
13.7k
                state: State::Open,
135
13.7k
                error: None,
136
13.7k
                go_away: GoAway::new(),
137
13.7k
                ping_pong: PingPong::new(),
138
13.7k
                settings: Settings::new(config.settings),
139
13.7k
                streams,
140
13.7k
                span,
141
13.7k
                _phantom: PhantomData,
142
13.7k
            },
143
13.7k
        }
144
13.7k
    }
145
146
    /// connection flow control
147
0
    pub(crate) fn set_target_window_size(&mut self, size: WindowSize) {
148
0
        let _res = self.inner.streams.set_target_connection_window_size(size);
149
        // TODO: proper error handling
150
0
        debug_assert!(_res.is_ok());
151
0
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::set_target_window_size
Unexecuted instantiation: <h2::proto::connection::Connection<h2_support::mock::Mock, h2::client::Peer>>::set_target_window_size
Unexecuted instantiation: <h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::set_target_window_size
152
153
    /// Send a new SETTINGS frame with an updated initial window size.
154
0
    pub(crate) fn set_initial_window_size(&mut self, size: WindowSize) -> Result<(), UserError> {
155
0
        let mut settings = frame::Settings::default();
156
0
        settings.set_initial_window_size(Some(size));
157
0
        self.inner.settings.send_settings(settings)
158
0
    }
159
160
    /// Send a new SETTINGS frame with extended CONNECT protocol enabled.
161
0
    pub(crate) fn set_enable_connect_protocol(&mut self) -> Result<(), UserError> {
162
0
        let mut settings = frame::Settings::default();
163
0
        settings.set_enable_connect_protocol(Some(1));
164
0
        self.inner.settings.send_settings(settings)
165
0
    }
166
167
    /// Returns the maximum number of concurrent streams that may be initiated
168
    /// by this peer.
169
0
    pub(crate) fn max_send_streams(&self) -> usize {
170
0
        self.inner.streams.max_send_streams()
171
0
    }
172
173
    /// Returns the maximum number of concurrent streams that may be initiated
174
    /// by the remote peer.
175
0
    pub(crate) fn max_recv_streams(&self) -> usize {
176
0
        self.inner.streams.max_recv_streams()
177
0
    }
178
179
    #[cfg(feature = "unstable")]
180
0
    pub fn num_wired_streams(&self) -> usize {
181
0
        self.inner.streams.num_wired_streams()
182
0
    }
183
184
    /// Returns `Ready` when the connection is ready to receive a frame.
185
    ///
186
    /// Returns `Error` as this may raise errors that are caused by delayed
187
    /// processing of received frames.
188
591k
    fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Error>> {
189
591k
        let _e = self.inner.span.enter();
190
591k
        let span = tracing::trace_span!("poll_ready");
191
591k
        let _e = span.enter();
192
        // The order of these calls don't really matter too much
193
591k
        ready!(self.inner.ping_pong.send_pending_pong(cx, &mut self.codec))?;
194
590k
        ready!(self.inner.ping_pong.send_pending_ping(cx, &mut self.codec))?;
195
590k
        ready!(self
196
590k
            .inner
197
590k
            .settings
198
590k
            .poll_send(cx, &mut self.codec, &mut self.inner.streams))?;
199
588k
        ready!(self.inner.streams.send_pending_refusal(cx, &mut self.codec))?;
200
201
588k
        Poll::Ready(Ok(()))
202
591k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::poll_ready
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::poll_ready
Line
Count
Source
188
591k
    fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Error>> {
189
591k
        let _e = self.inner.span.enter();
190
591k
        let span = tracing::trace_span!("poll_ready");
191
591k
        let _e = span.enter();
192
        // The order of these calls don't really matter too much
193
591k
        ready!(self.inner.ping_pong.send_pending_pong(cx, &mut self.codec))?;
194
590k
        ready!(self.inner.ping_pong.send_pending_ping(cx, &mut self.codec))?;
195
590k
        ready!(self
196
590k
            .inner
197
590k
            .settings
198
590k
            .poll_send(cx, &mut self.codec, &mut self.inner.streams))?;
199
588k
        ready!(self.inner.streams.send_pending_refusal(cx, &mut self.codec))?;
200
201
588k
        Poll::Ready(Ok(()))
202
591k
    }
203
204
    /// Send any pending GOAWAY frames.
205
    ///
206
    /// This will return `Some(reason)` if the connection should be closed
207
    /// afterwards. If this is a graceful shutdown, this returns `None`.
208
598k
    fn poll_go_away(&mut self, cx: &mut Context) -> Poll<Option<io::Result<Reason>>> {
209
598k
        self.inner.go_away.send_pending_go_away(cx, &mut self.codec)
210
598k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::poll_go_away
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::poll_go_away
Line
Count
Source
208
598k
    fn poll_go_away(&mut self, cx: &mut Context) -> Poll<Option<io::Result<Reason>>> {
209
598k
        self.inner.go_away.send_pending_go_away(cx, &mut self.codec)
210
598k
    }
211
212
0
    pub fn go_away_from_user(&mut self, e: Reason) {
213
0
        self.inner.as_dyn().go_away_from_user(e)
214
0
    }
215
216
1.26k
    fn take_error(&mut self, ours: Reason, initiator: Initiator) -> Result<(), Error> {
217
1.26k
        let (debug_data, theirs) = self
218
1.26k
            .inner
219
1.26k
            .error
220
1.26k
            .take()
221
1.26k
            .as_ref()
222
1.26k
            .map_or((Bytes::new(), Reason::NO_ERROR), |frame| {
223
129
                (frame.debug_data().clone(), frame.reason())
224
129
            });
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::take_error::{closure#0}
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::take_error::{closure#0}
Line
Count
Source
222
129
            .map_or((Bytes::new(), Reason::NO_ERROR), |frame| {
223
129
                (frame.debug_data().clone(), frame.reason())
224
129
            });
225
226
1.26k
        match (ours, theirs) {
227
991
            (Reason::NO_ERROR, Reason::NO_ERROR) => Ok(()),
228
153
            (ours, Reason::NO_ERROR) => Err(Error::GoAway(Bytes::new(), ours, initiator)),
229
            // If both sides reported an error, give their
230
            // error back to th user. We assume our error
231
            // was a consequence of their error, and less
232
            // important.
233
121
            (_, theirs) => Err(Error::remote_go_away(debug_data, theirs)),
234
        }
235
1.26k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::take_error
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::take_error
Line
Count
Source
216
1.26k
    fn take_error(&mut self, ours: Reason, initiator: Initiator) -> Result<(), Error> {
217
1.26k
        let (debug_data, theirs) = self
218
1.26k
            .inner
219
1.26k
            .error
220
1.26k
            .take()
221
1.26k
            .as_ref()
222
1.26k
            .map_or((Bytes::new(), Reason::NO_ERROR), |frame| {
223
                (frame.debug_data().clone(), frame.reason())
224
            });
225
226
1.26k
        match (ours, theirs) {
227
991
            (Reason::NO_ERROR, Reason::NO_ERROR) => Ok(()),
228
153
            (ours, Reason::NO_ERROR) => Err(Error::GoAway(Bytes::new(), ours, initiator)),
229
            // If both sides reported an error, give their
230
            // error back to th user. We assume our error
231
            // was a consequence of their error, and less
232
            // important.
233
121
            (_, theirs) => Err(Error::remote_go_away(debug_data, theirs)),
234
        }
235
1.26k
    }
236
237
    /// Closes the connection by transitioning to a GOAWAY state
238
    /// iff there are no streams or references
239
467k
    pub fn maybe_close_connection_if_no_streams(&mut self) {
240
        // If we poll() and realize that there are no streams or references
241
        // then we can close the connection by transitioning to GOAWAY
242
467k
        if !self.inner.streams.has_streams_or_other_references() {
243
0
            self.inner.as_dyn().go_away_now(Reason::NO_ERROR);
244
467k
        }
245
467k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::maybe_close_connection_if_no_streams
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::maybe_close_connection_if_no_streams
Line
Count
Source
239
467k
    pub fn maybe_close_connection_if_no_streams(&mut self) {
240
        // If we poll() and realize that there are no streams or references
241
        // then we can close the connection by transitioning to GOAWAY
242
467k
        if !self.inner.streams.has_streams_or_other_references() {
243
0
            self.inner.as_dyn().go_away_now(Reason::NO_ERROR);
244
467k
        }
245
467k
    }
246
247
    /// Checks if there are any streams
248
0
    pub fn has_streams(&self) -> bool {
249
0
        self.inner.streams.has_streams()
250
0
    }
251
252
    /// Checks if there are any streams or references left
253
921k
    pub fn has_streams_or_other_references(&self) -> bool {
254
        // If we poll() and realize that there are no streams or references
255
        // then we can close the connection by transitioning to GOAWAY
256
921k
        self.inner.streams.has_streams_or_other_references()
257
921k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::has_streams_or_other_references
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::has_streams_or_other_references
Line
Count
Source
253
921k
    pub fn has_streams_or_other_references(&self) -> bool {
254
        // If we poll() and realize that there are no streams or references
255
        // then we can close the connection by transitioning to GOAWAY
256
921k
        self.inner.streams.has_streams_or_other_references()
257
921k
    }
258
259
0
    pub(crate) fn take_user_pings(&mut self) -> Option<UserPings> {
260
0
        self.inner.ping_pong.take_user_pings()
261
0
    }
262
263
    /// Advances the internal state of the connection.
264
467k
    pub fn poll(&mut self, cx: &mut Context) -> Poll<Result<(), Error>> {
265
        // XXX(eliza): cloning the span is unfortunately necessary here in
266
        // order to placate the borrow checker — `self` is mutably borrowed by
267
        // `poll2`, which means that we can't borrow `self.span` to enter it.
268
        // The clone is just an atomic ref bump.
269
467k
        let span = self.inner.span.clone();
270
467k
        let _e = span.enter();
271
467k
        let span = tracing::trace_span!("poll");
272
467k
        let _e = span.enter();
273
274
        loop {
275
539k
            tracing::trace!(connection.state = ?self.inner.state);
276
            // TODO: probably clean up this glob of code
277
539k
            match self.inner.state {
278
                // When open, continue to poll a frame
279
                State::Open => {
280
526k
                    let result = match self.poll2(cx) {
281
71.7k
                        Poll::Ready(result) => result,
282
                        // The connection is not ready to make progress
283
                        Poll::Pending => {
284
                            // Ensure all window updates have been sent.
285
                            //
286
                            // This will also handle flushing `self.codec`
287
454k
                            ready!(self.inner.streams.poll_complete(cx, &mut self.codec))?;
288
289
142k
                            if (self.inner.error.is_some()
290
142k
                                || self.inner.go_away.should_close_on_idle())
291
542
                                && !self.inner.streams.has_streams()
292
                            {
293
33
                                self.inner.as_dyn().go_away_now(Reason::NO_ERROR);
294
33
                                continue;
295
142k
                            }
296
297
142k
                            return Poll::Pending;
298
                        }
299
                    };
300
301
71.7k
                    self.inner.as_dyn().handle_poll2_result(result)?
302
                }
303
12.2k
                State::Closing(reason, initiator) => {
304
12.2k
                    tracing::trace!("connection closing after flush");
305
                    // Flush/shutdown the codec
306
12.2k
                    ready!(self.codec.shutdown(cx))?;
307
308
                    // Transition the state to error
309
1.26k
                    self.inner.state = State::Closed(reason, initiator);
310
                }
311
1.26k
                State::Closed(reason, initiator) => {
312
1.26k
                    return Poll::Ready(self.take_error(reason, initiator));
313
                }
314
            }
315
        }
316
467k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::poll
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::poll
Line
Count
Source
264
467k
    pub fn poll(&mut self, cx: &mut Context) -> Poll<Result<(), Error>> {
265
        // XXX(eliza): cloning the span is unfortunately necessary here in
266
        // order to placate the borrow checker — `self` is mutably borrowed by
267
        // `poll2`, which means that we can't borrow `self.span` to enter it.
268
        // The clone is just an atomic ref bump.
269
467k
        let span = self.inner.span.clone();
270
467k
        let _e = span.enter();
271
467k
        let span = tracing::trace_span!("poll");
272
467k
        let _e = span.enter();
273
274
        loop {
275
539k
            tracing::trace!(connection.state = ?self.inner.state);
276
            // TODO: probably clean up this glob of code
277
539k
            match self.inner.state {
278
                // When open, continue to poll a frame
279
                State::Open => {
280
526k
                    let result = match self.poll2(cx) {
281
71.7k
                        Poll::Ready(result) => result,
282
                        // The connection is not ready to make progress
283
                        Poll::Pending => {
284
                            // Ensure all window updates have been sent.
285
                            //
286
                            // This will also handle flushing `self.codec`
287
454k
                            ready!(self.inner.streams.poll_complete(cx, &mut self.codec))?;
288
289
142k
                            if (self.inner.error.is_some()
290
142k
                                || self.inner.go_away.should_close_on_idle())
291
542
                                && !self.inner.streams.has_streams()
292
                            {
293
33
                                self.inner.as_dyn().go_away_now(Reason::NO_ERROR);
294
33
                                continue;
295
142k
                            }
296
297
142k
                            return Poll::Pending;
298
                        }
299
                    };
300
301
71.7k
                    self.inner.as_dyn().handle_poll2_result(result)?
302
                }
303
12.2k
                State::Closing(reason, initiator) => {
304
12.2k
                    tracing::trace!("connection closing after flush");
305
                    // Flush/shutdown the codec
306
12.2k
                    ready!(self.codec.shutdown(cx))?;
307
308
                    // Transition the state to error
309
1.26k
                    self.inner.state = State::Closed(reason, initiator);
310
                }
311
1.26k
                State::Closed(reason, initiator) => {
312
1.26k
                    return Poll::Ready(self.take_error(reason, initiator));
313
                }
314
            }
315
        }
316
467k
    }
317
318
526k
    fn poll2(&mut self, cx: &mut Context) -> Poll<Result<(), Error>> {
319
        // This happens outside of the loop to prevent needing to do a clock
320
        // check and then comparison of the queue possibly multiple times a
321
        // second (and thus, the clock wouldn't have changed enough to matter).
322
526k
        self.clear_expired_reset_streams();
323
324
        loop {
325
            // First, ensure that the `Connection` is able to receive a frame
326
            //
327
            // The order here matters:
328
            // - poll_go_away may buffer a graceful shutdown GOAWAY frame
329
            // - If it has, we've also added a PING to be sent in poll_ready
330
598k
            if let Some(reason) = ready!(self.poll_go_away(cx)?) {
331
6.55k
                if self.inner.go_away.should_close_now() {
332
6.55k
                    if self.inner.go_away.is_user_initiated() {
333
                        // A user initiated abrupt shutdown shouldn't return
334
                        // the same error back to the user.
335
0
                        return Poll::Ready(Ok(()));
336
                    } else {
337
6.55k
                        return Poll::Ready(Err(Error::library_go_away(reason)));
338
                    }
339
0
                }
340
                // Only NO_ERROR should be waiting for idle
341
0
                debug_assert_eq!(
342
                    reason,
343
                    Reason::NO_ERROR,
344
0
                    "graceful GOAWAY should be NO_ERROR"
345
                );
346
591k
            }
347
591k
            ready!(self.poll_ready(cx))?;
348
349
588k
            match self
350
588k
                .inner
351
588k
                .as_dyn()
352
588k
                .recv_frame(ready!(Pin::new(&mut self.codec).poll_next(cx)?))?
353
            {
354
6.64k
                ReceivedFrame::Settings(frame) => {
355
6.64k
                    self.inner.settings.recv_settings(
356
6.64k
                        frame,
357
6.64k
                        &mut self.codec,
358
6.64k
                        &mut self.inner.streams,
359
1
                    )?;
360
                }
361
65.4k
                ReceivedFrame::Continue => (),
362
                ReceivedFrame::Done => {
363
5.16k
                    return Poll::Ready(Ok(()));
364
                }
365
            }
366
        }
367
526k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::poll2
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::poll2
Line
Count
Source
318
526k
    fn poll2(&mut self, cx: &mut Context) -> Poll<Result<(), Error>> {
319
        // This happens outside of the loop to prevent needing to do a clock
320
        // check and then comparison of the queue possibly multiple times a
321
        // second (and thus, the clock wouldn't have changed enough to matter).
322
526k
        self.clear_expired_reset_streams();
323
324
        loop {
325
            // First, ensure that the `Connection` is able to receive a frame
326
            //
327
            // The order here matters:
328
            // - poll_go_away may buffer a graceful shutdown GOAWAY frame
329
            // - If it has, we've also added a PING to be sent in poll_ready
330
598k
            if let Some(reason) = ready!(self.poll_go_away(cx)?) {
331
6.55k
                if self.inner.go_away.should_close_now() {
332
6.55k
                    if self.inner.go_away.is_user_initiated() {
333
                        // A user initiated abrupt shutdown shouldn't return
334
                        // the same error back to the user.
335
0
                        return Poll::Ready(Ok(()));
336
                    } else {
337
6.55k
                        return Poll::Ready(Err(Error::library_go_away(reason)));
338
                    }
339
0
                }
340
                // Only NO_ERROR should be waiting for idle
341
0
                debug_assert_eq!(
342
                    reason,
343
                    Reason::NO_ERROR,
344
0
                    "graceful GOAWAY should be NO_ERROR"
345
                );
346
591k
            }
347
591k
            ready!(self.poll_ready(cx))?;
348
349
588k
            match self
350
588k
                .inner
351
588k
                .as_dyn()
352
588k
                .recv_frame(ready!(Pin::new(&mut self.codec).poll_next(cx)?))?
353
            {
354
6.64k
                ReceivedFrame::Settings(frame) => {
355
6.64k
                    self.inner.settings.recv_settings(
356
6.64k
                        frame,
357
6.64k
                        &mut self.codec,
358
6.64k
                        &mut self.inner.streams,
359
1
                    )?;
360
                }
361
65.4k
                ReceivedFrame::Continue => (),
362
                ReceivedFrame::Done => {
363
5.16k
                    return Poll::Ready(Ok(()));
364
                }
365
            }
366
        }
367
526k
    }
368
369
526k
    fn clear_expired_reset_streams(&mut self) {
370
526k
        self.inner.streams.clear_expired_reset_streams();
371
526k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _>>::clear_expired_reset_streams
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::clear_expired_reset_streams
Line
Count
Source
369
526k
    fn clear_expired_reset_streams(&mut self) {
370
526k
        self.inner.streams.clear_expired_reset_streams();
371
526k
    }
372
}
373
374
impl<P, B> ConnectionInner<P, B>
375
where
376
    P: Peer,
377
    B: Buf,
378
{
379
659k
    fn as_dyn(&mut self) -> DynConnection<'_, B> {
380
        let ConnectionInner {
381
659k
            state,
382
659k
            go_away,
383
659k
            streams,
384
659k
            error,
385
659k
            ping_pong,
386
            ..
387
659k
        } = self;
388
659k
        let streams = streams.as_dyn();
389
659k
        DynConnection {
390
659k
            state,
391
659k
            go_away,
392
659k
            streams,
393
659k
            error,
394
659k
            ping_pong,
395
659k
        }
396
659k
    }
Unexecuted instantiation: <h2::proto::connection::ConnectionInner<_, _>>::as_dyn
<h2::proto::connection::ConnectionInner<h2::client::Peer>>::as_dyn
Line
Count
Source
379
659k
    fn as_dyn(&mut self) -> DynConnection<'_, B> {
380
        let ConnectionInner {
381
659k
            state,
382
659k
            go_away,
383
659k
            streams,
384
659k
            error,
385
659k
            ping_pong,
386
            ..
387
659k
        } = self;
388
659k
        let streams = streams.as_dyn();
389
659k
        DynConnection {
390
659k
            state,
391
659k
            go_away,
392
659k
            streams,
393
659k
            error,
394
659k
            ping_pong,
395
659k
        }
396
659k
    }
397
}
398
399
impl<B> DynConnection<'_, B>
400
where
401
    B: Buf,
402
{
403
0
    fn go_away(&mut self, id: StreamId, e: Reason) {
404
0
        let frame = frame::GoAway::new(id, e);
405
0
        self.streams.send_go_away(id);
406
0
        self.go_away.go_away(frame);
407
0
    }
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::go_away
Unexecuted instantiation: <h2::proto::connection::DynConnection>::go_away
408
409
33
    fn go_away_now(&mut self, e: Reason) {
410
33
        let last_processed_id = self.streams.last_processed_id();
411
33
        let frame = frame::GoAway::new(last_processed_id, e);
412
33
        self.go_away.go_away_now(frame);
413
33
    }
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::go_away_now
<h2::proto::connection::DynConnection>::go_away_now
Line
Count
Source
409
33
    fn go_away_now(&mut self, e: Reason) {
410
33
        let last_processed_id = self.streams.last_processed_id();
411
33
        let frame = frame::GoAway::new(last_processed_id, e);
412
33
        self.go_away.go_away_now(frame);
413
33
    }
414
415
6.72k
    fn go_away_now_data(&mut self, e: Reason, data: Bytes) {
416
6.72k
        let last_processed_id = self.streams.last_processed_id();
417
6.72k
        let frame = frame::GoAway::with_debug_data(last_processed_id, e, data);
418
6.72k
        self.go_away.go_away_now(frame);
419
6.72k
    }
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::go_away_now_data
<h2::proto::connection::DynConnection>::go_away_now_data
Line
Count
Source
415
6.72k
    fn go_away_now_data(&mut self, e: Reason, data: Bytes) {
416
6.72k
        let last_processed_id = self.streams.last_processed_id();
417
6.72k
        let frame = frame::GoAway::with_debug_data(last_processed_id, e, data);
418
6.72k
        self.go_away.go_away_now(frame);
419
6.72k
    }
420
421
0
    fn go_away_from_user(&mut self, e: Reason) {
422
0
        let last_processed_id = self.streams.last_processed_id();
423
0
        let frame = frame::GoAway::new(last_processed_id, e);
424
0
        self.go_away.go_away_from_user(frame);
425
426
        // Notify all streams of reason we're abruptly closing.
427
0
        self.streams.handle_error(Error::user_go_away(e));
428
0
    }
429
430
71.7k
    fn handle_poll2_result(&mut self, result: Result<(), Error>) -> Result<(), Error> {
431
66.5k
        match result {
432
            // The connection has shutdown normally
433
            Ok(()) => {
434
5.16k
                *self.state = State::Closing(Reason::NO_ERROR, Initiator::Library);
435
5.16k
                Ok(())
436
            }
437
            // Attempting to read a frame resulted in a connection level
438
            // error. This is handled by setting a GOAWAY frame followed by
439
            // terminating the connection.
440
13.2k
            Err(Error::GoAway(debug_data, reason, initiator)) => {
441
13.2k
                self.handle_go_away(reason, debug_data, initiator);
442
13.2k
                Ok(())
443
            }
444
            // Attempting to read a frame resulted in a stream level error.
445
            // This is handled by resetting the frame then trying to read
446
            // another frame.
447
52.0k
            Err(Error::Reset(id, reason, initiator)) => {
448
52.0k
                debug_assert_eq!(initiator, Initiator::Library);
449
52.0k
                tracing::trace!(?id, ?reason, "stream error");
450
52.0k
                match self.streams.send_reset(id, reason) {
451
52.0k
                    Ok(()) => (),
452
0
                    Err(crate::proto::error::GoAway { debug_data, reason }) => {
453
0
                        self.handle_go_away(reason, debug_data, Initiator::Library);
454
0
                    }
455
                }
456
52.0k
                Ok(())
457
            }
458
            // Attempting to read a frame resulted in an I/O error. All
459
            // active streams must be reset.
460
            //
461
            // TODO: Are I/O errors recoverable?
462
1.22k
            Err(Error::Io(kind, inner)) => {
463
1.22k
                tracing::debug!(error = ?kind, "Connection::poll; IO error");
464
1.22k
                let e = Error::Io(kind, inner);
465
466
                // Reset all active streams
467
1.22k
                self.streams.handle_error(e.clone());
468
469
                // Some client implementations drop the connections without notifying its peer
470
                // Attempting to read after the client dropped the connection results in UnexpectedEof
471
                // If as a server, we don't have anything more to send, just close the connection
472
                // without error
473
                //
474
                // See https://github.com/hyperium/hyper/issues/3427
475
1.22k
                if self.streams.is_buffer_empty()
476
1.22k
                    && matches!(kind, io::ErrorKind::UnexpectedEof)
477
0
                    && (self.streams.is_server()
478
0
                        || self.error.as_ref().map(|f| f.reason() == Reason::NO_ERROR)
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::handle_poll2_result::{closure#0}
Unexecuted instantiation: <h2::proto::connection::DynConnection>::handle_poll2_result::{closure#0}
479
0
                            == Some(true))
480
                {
481
0
                    *self.state = State::Closed(Reason::NO_ERROR, Initiator::Library);
482
0
                    return Ok(());
483
1.22k
                }
484
485
                // Return the error
486
1.22k
                Err(e)
487
            }
488
        }
489
71.7k
    }
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::handle_poll2_result
<h2::proto::connection::DynConnection>::handle_poll2_result
Line
Count
Source
430
71.7k
    fn handle_poll2_result(&mut self, result: Result<(), Error>) -> Result<(), Error> {
431
66.5k
        match result {
432
            // The connection has shutdown normally
433
            Ok(()) => {
434
5.16k
                *self.state = State::Closing(Reason::NO_ERROR, Initiator::Library);
435
5.16k
                Ok(())
436
            }
437
            // Attempting to read a frame resulted in a connection level
438
            // error. This is handled by setting a GOAWAY frame followed by
439
            // terminating the connection.
440
13.2k
            Err(Error::GoAway(debug_data, reason, initiator)) => {
441
13.2k
                self.handle_go_away(reason, debug_data, initiator);
442
13.2k
                Ok(())
443
            }
444
            // Attempting to read a frame resulted in a stream level error.
445
            // This is handled by resetting the frame then trying to read
446
            // another frame.
447
52.0k
            Err(Error::Reset(id, reason, initiator)) => {
448
52.0k
                debug_assert_eq!(initiator, Initiator::Library);
449
52.0k
                tracing::trace!(?id, ?reason, "stream error");
450
52.0k
                match self.streams.send_reset(id, reason) {
451
52.0k
                    Ok(()) => (),
452
0
                    Err(crate::proto::error::GoAway { debug_data, reason }) => {
453
0
                        self.handle_go_away(reason, debug_data, Initiator::Library);
454
0
                    }
455
                }
456
52.0k
                Ok(())
457
            }
458
            // Attempting to read a frame resulted in an I/O error. All
459
            // active streams must be reset.
460
            //
461
            // TODO: Are I/O errors recoverable?
462
1.22k
            Err(Error::Io(kind, inner)) => {
463
1.22k
                tracing::debug!(error = ?kind, "Connection::poll; IO error");
464
1.22k
                let e = Error::Io(kind, inner);
465
466
                // Reset all active streams
467
1.22k
                self.streams.handle_error(e.clone());
468
469
                // Some client implementations drop the connections without notifying its peer
470
                // Attempting to read after the client dropped the connection results in UnexpectedEof
471
                // If as a server, we don't have anything more to send, just close the connection
472
                // without error
473
                //
474
                // See https://github.com/hyperium/hyper/issues/3427
475
1.22k
                if self.streams.is_buffer_empty()
476
1.22k
                    && matches!(kind, io::ErrorKind::UnexpectedEof)
477
0
                    && (self.streams.is_server()
478
0
                        || self.error.as_ref().map(|f| f.reason() == Reason::NO_ERROR)
479
0
                            == Some(true))
480
                {
481
0
                    *self.state = State::Closed(Reason::NO_ERROR, Initiator::Library);
482
0
                    return Ok(());
483
1.22k
                }
484
485
                // Return the error
486
1.22k
                Err(e)
487
            }
488
        }
489
71.7k
    }
490
491
13.2k
    fn handle_go_away(&mut self, reason: Reason, debug_data: Bytes, initiator: Initiator) {
492
13.2k
        let e = Error::GoAway(debug_data.clone(), reason, initiator);
493
13.2k
        tracing::debug!(error = ?e, "Connection::poll; connection error");
494
495
        // We may have already sent a GOAWAY for this error,
496
        // if so, don't send another, just flush and close up.
497
13.2k
        if self
498
13.2k
            .go_away
499
13.2k
            .going_away()
500
13.2k
            .map_or(false, |frame| frame.reason() == reason)
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::handle_go_away::{closure#0}
<h2::proto::connection::DynConnection>::handle_go_away::{closure#0}
Line
Count
Source
500
6.55k
            .map_or(false, |frame| frame.reason() == reason)
501
        {
502
6.55k
            tracing::trace!("    -> already going away");
503
6.55k
            *self.state = State::Closing(reason, initiator);
504
6.55k
            return;
505
6.72k
        }
506
507
        // Reset all active streams
508
6.72k
        self.streams.handle_error(e);
509
6.72k
        self.go_away_now_data(reason, debug_data);
510
13.2k
    }
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::handle_go_away
<h2::proto::connection::DynConnection>::handle_go_away
Line
Count
Source
491
13.2k
    fn handle_go_away(&mut self, reason: Reason, debug_data: Bytes, initiator: Initiator) {
492
13.2k
        let e = Error::GoAway(debug_data.clone(), reason, initiator);
493
13.2k
        tracing::debug!(error = ?e, "Connection::poll; connection error");
494
495
        // We may have already sent a GOAWAY for this error,
496
        // if so, don't send another, just flush and close up.
497
13.2k
        if self
498
13.2k
            .go_away
499
13.2k
            .going_away()
500
13.2k
            .map_or(false, |frame| frame.reason() == reason)
501
        {
502
6.55k
            tracing::trace!("    -> already going away");
503
6.55k
            *self.state = State::Closing(reason, initiator);
504
6.55k
            return;
505
6.72k
        }
506
507
        // Reset all active streams
508
6.72k
        self.streams.handle_error(e);
509
6.72k
        self.go_away_now_data(reason, debug_data);
510
13.2k
    }
511
512
96.8k
    fn recv_frame(&mut self, frame: Option<Frame>) -> Result<ReceivedFrame, Error> {
513
        use crate::frame::Frame::*;
514
91.7k
        match frame {
515
9.66k
            Some(Headers(frame)) => {
516
9.66k
                tracing::trace!(?frame, "recv HEADERS");
517
9.66k
                self.streams.recv_headers(frame)?;
518
            }
519
64.5k
            Some(Data(frame)) => {
520
64.5k
                tracing::trace!(?frame, "recv DATA");
521
64.5k
                self.streams.recv_data(frame)?;
522
            }
523
1.76k
            Some(Reset(frame)) => {
524
1.76k
                tracing::trace!(?frame, "recv RST_STREAM");
525
1.76k
                self.streams.recv_reset(frame)?;
526
            }
527
1.30k
            Some(PushPromise(frame)) => {
528
1.30k
                tracing::trace!(?frame, "recv PUSH_PROMISE");
529
1.30k
                self.streams.recv_push_promise(frame)?;
530
            }
531
6.64k
            Some(Settings(frame)) => {
532
6.64k
                tracing::trace!(?frame, "recv SETTINGS");
533
6.64k
                return Ok(ReceivedFrame::Settings(frame));
534
            }
535
5.29k
            Some(GoAway(frame)) => {
536
5.29k
                tracing::trace!(?frame, "recv GOAWAY");
537
                // This should prevent starting new streams,
538
                // but should allow continuing to process current streams
539
                // until they are all EOS. Once they are, State should
540
                // transition to GoAway.
541
5.29k
                self.streams.recv_go_away(&frame)?;
542
5.26k
                *self.error = Some(frame);
543
            }
544
587
            Some(Ping(frame)) => {
545
587
                tracing::trace!(?frame, "recv PING");
546
587
                let status = self.ping_pong.recv_ping(frame);
547
587
                if status.is_shutdown() {
548
0
                    assert!(
549
0
                        self.go_away.is_going_away(),
550
0
                        "received unexpected shutdown ping"
551
                    );
552
553
0
                    let last_processed_id = self.streams.last_processed_id();
554
0
                    self.go_away(last_processed_id, Reason::NO_ERROR);
555
587
                }
556
            }
557
1.82k
            Some(WindowUpdate(frame)) => {
558
1.82k
                tracing::trace!(?frame, "recv WINDOW_UPDATE");
559
1.82k
                self.streams.recv_window_update(frame)?;
560
            }
561
129
            Some(Priority(frame)) => {
562
129
                tracing::trace!(?frame, "recv PRIORITY");
563
                // TODO: handle
564
            }
565
            None => {
566
5.16k
                tracing::trace!("codec closed");
567
5.16k
                self.streams.recv_eof(false).expect("mutex poisoned");
568
5.16k
                return Ok(ReceivedFrame::Done);
569
            }
570
        }
571
65.4k
        Ok(ReceivedFrame::Continue)
572
96.8k
    }
Unexecuted instantiation: <h2::proto::connection::DynConnection<_>>::recv_frame
<h2::proto::connection::DynConnection>::recv_frame
Line
Count
Source
512
96.8k
    fn recv_frame(&mut self, frame: Option<Frame>) -> Result<ReceivedFrame, Error> {
513
        use crate::frame::Frame::*;
514
91.7k
        match frame {
515
9.66k
            Some(Headers(frame)) => {
516
9.66k
                tracing::trace!(?frame, "recv HEADERS");
517
9.66k
                self.streams.recv_headers(frame)?;
518
            }
519
64.5k
            Some(Data(frame)) => {
520
64.5k
                tracing::trace!(?frame, "recv DATA");
521
64.5k
                self.streams.recv_data(frame)?;
522
            }
523
1.76k
            Some(Reset(frame)) => {
524
1.76k
                tracing::trace!(?frame, "recv RST_STREAM");
525
1.76k
                self.streams.recv_reset(frame)?;
526
            }
527
1.30k
            Some(PushPromise(frame)) => {
528
1.30k
                tracing::trace!(?frame, "recv PUSH_PROMISE");
529
1.30k
                self.streams.recv_push_promise(frame)?;
530
            }
531
6.64k
            Some(Settings(frame)) => {
532
6.64k
                tracing::trace!(?frame, "recv SETTINGS");
533
6.64k
                return Ok(ReceivedFrame::Settings(frame));
534
            }
535
5.29k
            Some(GoAway(frame)) => {
536
5.29k
                tracing::trace!(?frame, "recv GOAWAY");
537
                // This should prevent starting new streams,
538
                // but should allow continuing to process current streams
539
                // until they are all EOS. Once they are, State should
540
                // transition to GoAway.
541
5.29k
                self.streams.recv_go_away(&frame)?;
542
5.26k
                *self.error = Some(frame);
543
            }
544
587
            Some(Ping(frame)) => {
545
587
                tracing::trace!(?frame, "recv PING");
546
587
                let status = self.ping_pong.recv_ping(frame);
547
587
                if status.is_shutdown() {
548
0
                    assert!(
549
0
                        self.go_away.is_going_away(),
550
0
                        "received unexpected shutdown ping"
551
                    );
552
553
0
                    let last_processed_id = self.streams.last_processed_id();
554
0
                    self.go_away(last_processed_id, Reason::NO_ERROR);
555
587
                }
556
            }
557
1.82k
            Some(WindowUpdate(frame)) => {
558
1.82k
                tracing::trace!(?frame, "recv WINDOW_UPDATE");
559
1.82k
                self.streams.recv_window_update(frame)?;
560
            }
561
129
            Some(Priority(frame)) => {
562
129
                tracing::trace!(?frame, "recv PRIORITY");
563
                // TODO: handle
564
            }
565
            None => {
566
5.16k
                tracing::trace!("codec closed");
567
5.16k
                self.streams.recv_eof(false).expect("mutex poisoned");
568
5.16k
                return Ok(ReceivedFrame::Done);
569
            }
570
        }
571
65.4k
        Ok(ReceivedFrame::Continue)
572
96.8k
    }
573
}
574
575
enum ReceivedFrame {
576
    Settings(frame::Settings),
577
    Continue,
578
    Done,
579
}
580
581
impl<T, B> Connection<T, client::Peer, B>
582
where
583
    T: AsyncRead + AsyncWrite,
584
    B: Buf,
585
{
586
14.5k
    pub(crate) fn streams(&self) -> &Streams<B, client::Peer> {
587
14.5k
        &self.inner.streams
588
14.5k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, h2::client::Peer, _>>::streams
<h2::proto::connection::Connection<h2_support::mock::Mock, h2::client::Peer>>::streams
Line
Count
Source
586
776
    pub(crate) fn streams(&self) -> &Streams<B, client::Peer> {
587
776
        &self.inner.streams
588
776
    }
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer>>::streams
Line
Count
Source
586
13.7k
    pub(crate) fn streams(&self) -> &Streams<B, client::Peer> {
587
13.7k
        &self.inner.streams
588
13.7k
    }
589
}
590
591
impl<T, B> Connection<T, server::Peer, B>
592
where
593
    T: AsyncRead + AsyncWrite + Unpin,
594
    B: Buf,
595
{
596
0
    pub fn next_incoming(&mut self) -> Option<StreamRef<B>> {
597
0
        self.inner.streams.next_incoming()
598
0
    }
599
600
    // Graceful shutdown only makes sense for server peers.
601
0
    pub fn go_away_gracefully(&mut self) {
602
0
        if self.inner.go_away.is_going_away() {
603
            // No reason to start a new one.
604
0
            return;
605
0
        }
606
607
        // According to http://httpwg.org/specs/rfc7540.html#GOAWAY:
608
        //
609
        // > A server that is attempting to gracefully shut down a connection
610
        // > SHOULD send an initial GOAWAY frame with the last stream
611
        // > identifier set to 2^31-1 and a NO_ERROR code. This signals to the
612
        // > client that a shutdown is imminent and that initiating further
613
        // > requests is prohibited. After allowing time for any in-flight
614
        // > stream creation (at least one round-trip time), the server can
615
        // > send another GOAWAY frame with an updated last stream identifier.
616
        // > This ensures that a connection can be cleanly shut down without
617
        // > losing requests.
618
0
        self.inner.as_dyn().go_away(StreamId::MAX, Reason::NO_ERROR);
619
620
        // We take the advice of waiting 1 RTT literally, and wait
621
        // for a pong before proceeding.
622
0
        self.inner.ping_pong.ping_shutdown();
623
0
    }
624
}
625
626
impl<T, P, B> Drop for Connection<T, P, B>
627
where
628
    P: Peer,
629
    B: Buf,
630
{
631
14.5k
    fn drop(&mut self) {
632
        // Ignore errors as this indicates that the mutex is poisoned.
633
14.5k
        let _ = self.inner.streams.recv_eof(true);
634
14.5k
    }
Unexecuted instantiation: <h2::proto::connection::Connection<_, _, _> as core::ops::drop::Drop>::drop
<h2::proto::connection::Connection<h2_support::mock::Mock, h2::client::Peer> as core::ops::drop::Drop>::drop
Line
Count
Source
631
776
    fn drop(&mut self) {
632
        // Ignore errors as this indicates that the mutex is poisoned.
633
776
        let _ = self.inner.streams.recv_eof(true);
634
776
    }
<h2::proto::connection::Connection<fuzz_e2e::MockIo, h2::client::Peer> as core::ops::drop::Drop>::drop
Line
Count
Source
631
13.7k
    fn drop(&mut self) {
632
        // Ignore errors as this indicates that the mutex is poisoned.
633
13.7k
        let _ = self.inner.streams.recv_eof(true);
634
13.7k
    }
635
}