Skip to content

Commit f2c1a91

Browse files
committed
async-client: remove client timeout
After the server-timeout feature had been introduced, the client timeout feature is unnecessary and can be removed. Signed-off-by: Tim Zhang <[email protected]>
1 parent ca3f1f8 commit f2c1a91

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/asynchronous/client.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use protobuf::{CodedInputStream, CodedOutputStream, Message};
88
use std::collections::HashMap;
99
use std::os::unix::io::RawFd;
1010
use std::sync::{Arc, Mutex};
11-
use std::time::Duration;
1211

1312
use crate::common::MESSAGE_TYPE_RESPONSE;
1413
use crate::error::{Error, Result};
@@ -21,7 +20,6 @@ use tokio::{
2120
io::{split, AsyncWriteExt},
2221
sync::mpsc::{channel, Receiver, Sender},
2322
sync::Notify,
24-
time::timeout,
2523
};
2624

2725
type RequestSender = Sender<(Vec<u8>, Sender<Result<Vec<u8>>>)>;
@@ -158,21 +156,10 @@ impl Client {
158156
.await
159157
.map_err(|e| Error::Others(format!("Send packet to sender error {:?}", e)))?;
160158

161-
let result: Result<Vec<u8>> = if req.timeout_nano == 0 {
162-
rx.recv()
163-
.await
164-
.ok_or_else(|| Error::Others("Recive packet from recver error".to_string()))?
165-
} else {
166-
match timeout(Duration::from_nanos(req.timeout_nano as u64), rx.recv()).await {
167-
Ok(result) => result
168-
.ok_or_else(|| Error::Others("Recive packet from recver error".to_string()))?,
169-
Err(_) => {
170-
return Err(Error::Others(
171-
"Recive packet from recver error: timeout".to_string(),
172-
))
173-
}
174-
}
175-
};
159+
let result = rx
160+
.recv()
161+
.await
162+
.ok_or_else(|| Error::Others("Recive packet from recver error".to_string()))?;
176163

177164
let buf = result?;
178165
let mut s = CodedInputStream::from_bytes(&buf);

0 commit comments

Comments
 (0)