Skip to content

Commit 02f6d2f

Browse files
committed
docs: add cancel safety section to TcpStream::peek
Fix #7303
1 parent 48ca254 commit 02f6d2f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tokio/src/net/tcp/stream.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,13 @@ impl TcpStream {
10701070
/// Successive calls return the same data. This is accomplished by passing
10711071
/// `MSG_PEEK` as a flag to the underlying `recv` system call.
10721072
///
1073+
/// # Cancel safety
1074+
///
1075+
/// This method is cancel safe. If the method is used as the event in a
1076+
/// [`tokio::select!`] statement and some other branch completes first,
1077+
/// then it is guranteed that no data was permanently read from the
1078+
/// stream's buffer.
1079+
///
10731080
/// # Examples
10741081
///
10751082
/// ```no_run

0 commit comments

Comments
 (0)