aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkbleeke <[email protected]>2023-02-22 13:57:40 +0100
committerkbleeke <[email protected]>2023-02-22 13:57:40 +0100
commitf1a4db44c4c3f591df378190a6604d4547a37c25 (patch)
tree9f74956a5928d9894a242d426344fe0598edd2c8
parentb05cd77a62bc8902db2ae2dd36ed58b88acee932 (diff)
Implement flush for TcpSocket
-rw-r--r--embassy-net/src/tcp.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs
index d46bd4dbf..b9e494fc4 100644
--- a/embassy-net/src/tcp.rs
+++ b/embassy-net/src/tcp.rs
@@ -254,10 +254,19 @@ impl<'d> TcpIo<'d> {
254 .await 254 .await
255 } 255 }
256 256
257 #[allow(unused)]
258 async fn flush(&mut self) -> Result<(), Error> { 257 async fn flush(&mut self) -> Result<(), Error> {
259 poll_fn(move |_| { 258 poll_fn(move |cx| {
260 Poll::Ready(Ok(())) // TODO: Is there a better implementation for this? 259 self.with_mut(|s, _| {
260 // If there are outstanding send operations, register for wake up and wait
261 // smoltcp issues wake-ups when octets are dequeued from the send buffer
262 if s.send_queue() > 0 {
263 s.register_send_waker(cx.waker());
264 Poll::Pending
265 // No outstanding sends, socket is flushed
266 } else {
267 Poll::Ready(Ok(()))
268 }
269 })
261 }) 270 })
262 .await 271 .await
263 } 272 }