Skip to content

Commit 910db8e

Browse files
committed
Fix Compile Errors
1 parent f05a77d commit 910db8e

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pubsub-client/src/nonblocking/pubsub_client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@
167167
//! ```
168168
169169
use {
170+
crate::pubsub_client::{DEFAULT_MAX_FAILED_PINGS, DEFAULT_PING_DURATION_SECONDS},
170171
futures_util::{
171172
future::{ready, BoxFuture, FutureExt},
172173
sink::SinkExt,
173174
stream::{BoxStream, StreamExt},
174175
},
175176
log::*,
176-
pubsub_client::{DEFAULT_MAX_FAILED_PINGS, DEFAULT_PING_DURATION_SECONDS},
177177
serde::de::DeserializeOwned,
178178
serde_json::{json, Map, Value},
179179
solana_account_decoder_client_types::UiAccount,

pubsub-client/src/pubsub_client.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,18 @@ impl PubsubClient {
837837
}
838838
}
839839

840-
// Read timeout to prevent indefinite blocking on `read_message`
841-
socket
842-
.write()
843-
.unwrap()
844-
.get_mut()
845-
.get_mut()
846-
.set_read_timeout(Some(Duration::from_millis(500)))
847-
.unwrap();
840+
let mut ws = socket.write().unwrap();
841+
let maybe_tls_stream = ws.get_mut();
842+
843+
match maybe_tls_stream {
844+
MaybeTlsStream::Plain(tcp_stream) => {
845+
if let Err(e) = tcp_stream.set_read_timeout(Some(Duration::from_millis(500))) {
846+
info!("Failed to set read timeout on TcpStream: {:?}", e);
847+
}
848+
}
849+
// We can only set a read time out safely if it's a plain TCP connection
850+
_ => {}
851+
}
848852

849853
match PubsubClientSubscription::read_message(socket) {
850854
Ok(Some(message)) => {

0 commit comments

Comments
 (0)