Skip to content

Commit 385ffb0

Browse files
committed
agent: don't force owning send data
Especially in the UDP case, this is not necessary.
1 parent af9198b commit 385ffb0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

stun-proto/src/agent.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,7 @@ pub enum StunAgentPollRet<'a> {
410410
WaitUntil(Instant),
411411
}
412412

413-
fn send_data(
414-
transport: TransportType,
415-
bytes: &[u8],
416-
from: SocketAddr,
417-
to: SocketAddr,
418-
) -> Transmit<'static> {
413+
fn send_data(transport: TransportType, bytes: &[u8], from: SocketAddr, to: SocketAddr) -> Transmit {
419414
match transport {
420415
TransportType::Udp => Transmit::new(bytes, transport, from, to),
421416
TransportType::Tcp => {
@@ -426,7 +421,6 @@ fn send_data(
426421
Transmit::new_owned(data.into_boxed_slice(), transport, from, to)
427422
}
428423
}
429-
.into_owned()
430424
}
431425

432426
#[derive(Debug)]
@@ -718,7 +712,9 @@ impl StunRequestState {
718712
return StunRequestPollRet::Cancelled;
719713
}
720714
self.last_send_time = Some(now);
721-
StunRequestPollRet::SendData(send_data(self.transport, &self.bytes, self.from, self.to))
715+
StunRequestPollRet::SendData(
716+
send_data(self.transport, &self.bytes, self.from, self.to).into_owned(),
717+
)
722718
}
723719
}
724720

0 commit comments

Comments
 (0)