Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Set timeout only on non-New sockets.
Browse files Browse the repository at this point in the history
  • Loading branch information
meqif committed Jun 22, 2015
1 parent bbdc85c commit cdd26e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ impl UtpSocket {

fn recv(&mut self, buf: &mut[u8]) -> Result<(usize,SocketAddr)> {
let mut b = [0; BUF_SIZE + HEADER_SIZE];
// if self.state != SocketState::New {
// debug!("setting read timeout of {} ms", self.congestion_timeout);
// self.socket.set_read_timeout(Some(self.congestion_timeout));
// }
let (read, src) = match self.socket.recv_timeout(&mut b, self.congestion_timeout as i64) {
let timeout = if self.state != SocketState::New {
debug!("setting read timeout of {} ms", self.congestion_timeout);
self.congestion_timeout as i64
} else { 0 };
let (read, src) = match self.socket.recv_timeout(&mut b, timeout) {
Err(ref e) if (e.kind() == ErrorKind::WouldBlock ||
e.kind() == ErrorKind::TimedOut) => {
debug!("recv_from timed out");
Expand Down

0 comments on commit cdd26e7

Please sign in to comment.