Skip to content

Commit

Permalink
Merge pull request #1455 from microsoft/wip-irene2
Browse files Browse the repository at this point in the history
[inetstack] Enhancement: replace immediate send
  • Loading branch information
iyzhang authored Nov 13, 2024
2 parents 6019bb6 + 01f96d5 commit a7f0053
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ impl SharedControlBlock {
}

pub async fn push(&mut self, buf: DemiBuffer) -> Result<(), Fail> {
self.sender.push(buf).await
let cb: Self = self.clone();
self.sender.push(buf, cb).await
}

pub async fn pop(&mut self, size: Option<usize>) -> Result<DemiBuffer, Fail> {
Expand Down
9 changes: 7 additions & 2 deletions src/rust/inetstack/protocols/layer4/tcp/established/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Sender {
}

// This function sends a packet and waits for it to be acked.
pub async fn push(&mut self, buf: DemiBuffer) -> Result<(), Fail> {
pub async fn push(&mut self, mut buf: DemiBuffer, mut cb: SharedControlBlock) -> Result<(), Fail> {
// If the user is done sending (i.e. has called close on this connection), then they shouldn't be sending.
debug_assert!(self.fin_seq_no.is_none());
// Our API supports send buffers up to usize (variable, depends upon architecture) in size. While we could
Expand All @@ -153,7 +153,12 @@ impl Sender {

// Place the buffer in the unsent queue.
self.unsent_next_seq_no = self.unsent_next_seq_no + (buf.len() as u32).into();
self.unsent_queue.push(Some(buf));
if self.send_window.get() > 0 {
self.send_segment(&mut buf, &mut cb);
}
if buf.len() > 0 {
self.unsent_queue.push(Some(buf));
}

// Wait until the sequnce number of the pushed buffer is acknowledged.
let mut send_unacked_watched: SharedAsyncValue<SeqNumber> = self.send_unacked.clone();
Expand Down

0 comments on commit a7f0053

Please sign in to comment.