Skip to content

Commit 8663b66

Browse files
committed
Corrected a hang in UDP and TCP mode when the server is behind a firewall that doesn't allow outbound traffic and reverse-mode is requested
1 parent ebf9d80 commit 8663b66

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/stream/tcp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ pub mod receiver {
133133
)?;
134134
let mut events = Events::with_capacity(1);
135135

136+
let start = Instant::now();
137+
136138
while self.active {
139+
if start.elapsed() >= RECEIVE_TIMEOUT {
140+
return Err(Box::new(simple_error::simple_error!("TCP listening for stream {} timed out", self.stream_idx)));
141+
}
142+
137143
poll.poll(&mut events, Some(POLL_TIMEOUT))?;
138144
for event in events.iter() {
139145
match event.token() {

src/stream/udp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ pub mod receiver {
282282
}
283283
},
284284
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { //receive timeout
285-
//break;
286-
continue;
285+
break;
287286
},
288287
Err(e) => {
289288
return Some(Err(Box::new(e)));

0 commit comments

Comments
 (0)