You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tokio/src/net/tcp/socket.rs
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -419,6 +419,17 @@ impl TcpSocket {
419
419
///
420
420
/// If `SO_LINGER` is not specified, and the socket is closed, the system handles the call in a
421
421
/// way that allows the process to continue as quickly as possible.
422
+
///
423
+
/// This option is deprecated because setting `SO_LINGER` on a socket used with Tokio is always
424
+
/// incorrect as it leads to blocking the thread when the socket is closed. For more details,
425
+
/// please see:
426
+
///
427
+
/// > Volumes of communications have been devoted to the intricacies of `SO_LINGER` versus
428
+
/// > non-blocking (`O_NONBLOCK`) sockets. From what I can tell, the final word is: don't do
429
+
/// > it. Rely on the `shutdown()`-followed-by-`read()`-eof technique instead.
430
+
/// >
431
+
/// > From [The ultimate `SO_LINGER` page, or: why is my tcp not reliable](https://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable)
432
+
#[deprecated = "`SO_LINGER` causes the socket to block the thread on drop"]
Copy file name to clipboardExpand all lines: tokio/src/net/tcp/stream.rs
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1278,9 +1278,20 @@ impl TcpStream {
1278
1278
/// If `SO_LINGER` is not specified, and the stream is closed, the system handles the call in a
1279
1279
/// way that allows the process to continue as quickly as possible.
1280
1280
///
1281
+
/// This option is deprecated because setting `SO_LINGER` on a socket used with Tokio is
1282
+
/// always incorrect as it leads to blocking the thread when the socket is closed. For more
1283
+
/// details, please see:
1284
+
///
1285
+
/// > Volumes of communications have been devoted to the intricacies of `SO_LINGER` versus
1286
+
/// > non-blocking (`O_NONBLOCK`) sockets. From what I can tell, the final word is: don't
1287
+
/// > do it. Rely on the `shutdown()`-followed-by-`read()`-eof technique instead.
1288
+
/// >
1289
+
/// > From [The ultimate `SO_LINGER` page, or: why is my tcp not reliable](https://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable)
0 commit comments