From 1c0a2265fef8f196850eb701c97c8dbbe53030f3 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Fri, 27 Sep 2024 13:21:37 +0200 Subject: [PATCH 1/8] Add files via upload --- tokio-stream/src/wrappers/broadcast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio-stream/src/wrappers/broadcast.rs b/tokio-stream/src/wrappers/broadcast.rs index 21677971d5f..b3900db8ff6 100644 --- a/tokio-stream/src/wrappers/broadcast.rs +++ b/tokio-stream/src/wrappers/broadcast.rs @@ -11,7 +11,7 @@ use std::task::{ready, Context, Poll}; /// A wrapper around [`tokio::sync::broadcast::Receiver`] that implements [`Stream`]. /// /// [`tokio::sync::broadcast::Receiver`]: struct@tokio::sync::broadcast::Receiver -/// [`Stream`]: trait@crate::Stream +/// [`Stream`]: trait@futures_core::Stream #[cfg_attr(docsrs, doc(cfg(feature = "sync")))] pub struct BroadcastStream { inner: ReusableBoxFuture<'static, (Result, Receiver)>, From 461924532c2fa48c8be40ce5a77913ebd23a233b Mon Sep 17 00:00:00 2001 From: shray sharma Date: Sun, 29 Sep 2024 16:08:42 +0200 Subject: [PATCH 2/8] seek_pos reset This ensures that seek_pos is only reset if the seek operation completed successfully. --- tokio-util/src/compat.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tokio-util/src/compat.rs b/tokio-util/src/compat.rs index b71e2b1b0f2..5484100fee4 100644 --- a/tokio-util/src/compat.rs +++ b/tokio-util/src/compat.rs @@ -254,8 +254,10 @@ impl tokio::io::AsyncSeek for Compat { } Some(pos) => pos, }; - let res = ready!(self.as_mut().project().inner.poll_seek(cx, pos)); - *self.as_mut().project().seek_pos = None; + let res = ready!(self.as_mut().project().inner.poll_complete(cx)); + if res.is_ok() { + *self.as_mut().project().seek_pos = None; + } Poll::Ready(res) } } From 505ea0651239f9b0d2e47b678a1064a918e18198 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Sun, 29 Sep 2024 16:19:47 +0200 Subject: [PATCH 3/8] upd --- tokio-util/src/compat.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tokio-util/src/compat.rs b/tokio-util/src/compat.rs index 5484100fee4..3c5ba0d6d28 100644 --- a/tokio-util/src/compat.rs +++ b/tokio-util/src/compat.rs @@ -232,7 +232,9 @@ impl futures_io::AsyncSeek for Compat { *self.as_mut().project().seek_pos = Some(pos); } let res = ready!(self.as_mut().project().inner.poll_complete(cx)); - *self.as_mut().project().seek_pos = None; + if res.is_ok() { + *self.as_mut().project().seek_pos = None; + } Poll::Ready(res) } } @@ -254,7 +256,7 @@ impl tokio::io::AsyncSeek for Compat { } Some(pos) => pos, }; - let res = ready!(self.as_mut().project().inner.poll_complete(cx)); + let res = ready!(self.as_mut().project().inner.poll_seek(cx, pos)); if res.is_ok() { *self.as_mut().project().seek_pos = None; } From 1d8f8aa0d315507d844133cf18ee43d7ff891fd0 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Thu, 12 Dec 2024 20:45:25 +0100 Subject: [PATCH 4/8] upd --- examples/chat.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/chat.rs b/examples/chat.rs index 1d8c6b04684..0a5c5505b24 100644 --- a/examples/chat.rs +++ b/examples/chat.rs @@ -141,7 +141,9 @@ impl Shared { async fn broadcast(&mut self, sender: SocketAddr, message: &str) { for peer in self.peers.iter_mut() { if *peer.0 != sender { - let _ = peer.1.send(message.into()); + if let Err(e) = peer.1.send(message.into()) { + tracing::error!("Failed to send message to {}: {:?}", peer.0, e); + } } } } From 695abfa0bc6d58f114a27410dfe5571aaca7e39c Mon Sep 17 00:00:00 2001 From: shray sharma Date: Thu, 12 Dec 2024 20:47:45 +0100 Subject: [PATCH 5/8] upd --- tokio/src/runtime/time/entry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/runtime/time/entry.rs b/tokio/src/runtime/time/entry.rs index 834077caa3d..556c0bd317b 100644 --- a/tokio/src/runtime/time/entry.rs +++ b/tokio/src/runtime/time/entry.rs @@ -500,7 +500,7 @@ impl TimerEntry { *self.inner.get() = Some(TimerShared::new(shard_id)); } } - return inner.as_ref().unwrap(); + inner.as_ref().unwrap() } pub(crate) fn deadline(&self) -> Instant { From 7ed1826cff3e0f1d81d2262f29a6ddce4f5f53c8 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Thu, 12 Dec 2024 20:48:50 +0100 Subject: [PATCH 6/8] upd --- tokio/src/sync/rwlock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/sync/rwlock.rs b/tokio/src/sync/rwlock.rs index ff02c7971d6..d94b6514306 100644 --- a/tokio/src/sync/rwlock.rs +++ b/tokio/src/sync/rwlock.rs @@ -1094,7 +1094,7 @@ impl From for RwLock { } } -impl Default for RwLock +impl Default for RwLock where T: Default, { From b7775e74695d70fa86b3bd881e56b92d478c4886 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Thu, 12 Dec 2024 20:49:39 +0100 Subject: [PATCH 7/8] upd --- tokio/tests/io_split.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tokio/tests/io_split.rs b/tokio/tests/io_split.rs index 9f17c9eb14e..8d4e2403ae9 100644 --- a/tokio/tests/io_split.rs +++ b/tokio/tests/io_split.rs @@ -104,9 +104,7 @@ fn method_delegation() { assert_eq!(1, w.write(&[b'x']).await.unwrap()); assert_eq!( 2, - w.write_vectored(&[io::IoSlice::new(&[b'x'])]) - .await - .unwrap() + w.write_vectored(&[io::IoSlice::new(b"x")]).await.unwrap() ); assert!(w.is_write_vectored()); From 601a5ea88ac3e8926a1fda98583b932a51bee289 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Thu, 12 Dec 2024 20:50:42 +0100 Subject: [PATCH 8/8] upd --- tokio/tests/tcp_accept.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/tests/tcp_accept.rs b/tokio/tests/tcp_accept.rs index 766304778df..8c2984294aa 100644 --- a/tokio/tests/tcp_accept.rs +++ b/tokio/tests/tcp_accept.rs @@ -54,7 +54,7 @@ struct TrackPolls<'a> { listener: &'a mut TcpListener, } -impl<'a> Stream for TrackPolls<'a> { +impl Stream for TrackPolls<'_> { type Item = io::Result<(TcpStream, SocketAddr)>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {