Skip to content

Commit 52b8d96

Browse files
committed
Set TcpStream to nonblocking
1 parent a15fbe4 commit 52b8d96

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightning-block-sync/src/http_clients.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ impl HttpClient {
6161
stream.set_write_timeout(Some(Duration::from_secs(1)))?;
6262

6363
#[cfg(feature = "tokio")]
64-
let stream = TcpStream::from_std(stream)?;
64+
let stream = {
65+
stream.set_nonblocking(true)?;
66+
TcpStream::from_std(stream)?
67+
};
6568

6669
Ok(Self { stream })
6770
}
@@ -296,8 +299,6 @@ struct ReadAdapter<'a, R: tokio::io::AsyncRead + std::marker::Unpin>(&'a mut R);
296299
#[cfg(feature = "tokio")]
297300
impl<'a, R: tokio::io::AsyncRead + std::marker::Unpin> std::io::Read for ReadAdapter<'a, R> {
298301
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
299-
#[cfg(test)]
300-
std::thread::yield_now();
301302
futures::executor::block_on(self.0.read(buf))
302303
}
303304
}
@@ -655,7 +656,6 @@ mod tests {
655656
None => {
656657
stream.write(chunk).unwrap();
657658
stream.flush().unwrap();
658-
std::thread::yield_now();
659659
},
660660
Some(_) => break,
661661
}

0 commit comments

Comments
 (0)