From 64ae3734c653e1cbc900eef7f581a52a68cc8ada Mon Sep 17 00:00:00 2001
From: Stuart Hunt <onno.owl@gmail.com>
Date: Wed, 15 Nov 2023 12:16:14 -0500
Subject: [PATCH] Formatted

---
 sctp/src/association/mod.rs | 41 ++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/sctp/src/association/mod.rs b/sctp/src/association/mod.rs
index 08baca447..f56b80933 100644
--- a/sctp/src/association/mod.rs
+++ b/sctp/src/association/mod.rs
@@ -501,32 +501,35 @@ impl Association {
             let done2 = Arc::clone(&done);
             let mut buffer = None;
             for raw in packets {
-                let mut buf = buffer.take().unwrap_or_else(|| BytesMut::with_capacity(16 * 1024));
+                let mut buf = buffer
+                    .take()
+                    .unwrap_or_else(|| BytesMut::with_capacity(16 * 1024));
 
                 // We do the marshalling work in a blocking task here for a reason:
                 // If we don't tokio tends to run the write_loop and read_loop of one connection on the same OS thread
                 // This means that even though we release the lock above, the read_loop isn't able to take it, simply because it is not being scheduled by tokio
                 // Doing it this way, tokio schedules this work on a dedicated blocking thread, this future is suspended, and the read_loop can make progress
-                match tokio::task::spawn_blocking(move || {
-                    raw.marshal_to(&mut buf).map(|_| buf)
-                }).await.unwrap() {
-                        Ok(mut buf) => {
-                            let raw = buf.as_ref();
-                            if let Err(err) = net_conn.send(raw.as_ref()).await {
-                                log::warn!("[{}] failed to write packets on net_conn: {}", name2, err);
-                                done2.store(true, Ordering::Relaxed)
-                            } else {
-                                bytes_sent.fetch_add(raw.len(), Ordering::SeqCst);
-                            }
-
-                            // Reuse allocation. Have to use options, since spawn blocking can't borrow, has to take owernship.
-                            buf.clear();
-                            buffer = Some(buf);
-                        },
-                        Err(err) => {
-                            log::warn!("[{}] failed to serialize a packet: {:?}", name2, err);
+                match tokio::task::spawn_blocking(move || raw.marshal_to(&mut buf).map(|_| buf))
+                    .await
+                    .unwrap()
+                {
+                    Ok(mut buf) => {
+                        let raw = buf.as_ref();
+                        if let Err(err) = net_conn.send(raw.as_ref()).await {
+                            log::warn!("[{}] failed to write packets on net_conn: {}", name2, err);
+                            done2.store(true, Ordering::Relaxed)
+                        } else {
+                            bytes_sent.fetch_add(raw.len(), Ordering::SeqCst);
                         }
+
+                        // Reuse allocation. Have to use options, since spawn blocking can't borrow, has to take owernship.
+                        buf.clear();
+                        buffer = Some(buf);
                     }
+                    Err(err) => {
+                        log::warn!("[{}] failed to serialize a packet: {:?}", name2, err);
+                    }
+                }
                 //log::debug!("[{}] sending {} bytes done", name, raw.len());
             }