Skip to content

Commit

Permalink
Don't allocate an endpoint response buffer for every driver wakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Dec 21, 2023
1 parent 470b213 commit 7b6a448
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions quinn/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,6 @@ impl State {
.write(IoSliceMut::<'a>::new(buf));
});
let mut iovs = unsafe { iovs.assume_init() };
let buffer_size = self.inner.config().get_max_udp_payload_size() as usize;
let mut buffer = BytesMut::with_capacity(buffer_size);
loop {
match self.socket.poll_recv(cx, &mut iovs, &mut metas) {
Poll::Ready(Ok(msgs)) => {
Expand All @@ -418,13 +416,14 @@ impl State {
let mut data: BytesMut = buf[0..meta.len].into();
while !data.is_empty() {
let buf = data.split_to(meta.stride.min(data.len()));
let mut response_buffer = BytesMut::new();
match self.inner.handle(
now,
meta.addr,
meta.dst_ip,
meta.ecn.map(proto_ecn),
buf,
&mut buffer,
&mut response_buffer,
) {
Some(DatagramEvent::NewConnection(handle, conn)) => {
let conn = self.connections.insert(
Expand Down Expand Up @@ -455,7 +454,7 @@ impl State {
let contents_len = transmit.size;
self.outgoing.push_back(udp_transmit(
transmit,
buffer.split_to(contents_len).freeze(),
response_buffer.split_to(contents_len).freeze(),
));
self.transmit_queue_contents_len = self
.transmit_queue_contents_len
Expand Down

0 comments on commit 7b6a448

Please sign in to comment.