diff --git a/src/asynchronous/client.rs b/src/asynchronous/client.rs index ed2ee3a8..d21f6779 100644 --- a/src/asynchronous/client.rs +++ b/src/asynchronous/client.rs @@ -33,6 +33,7 @@ pub struct Client { req_tx: MessageSender, next_stream_id: Arc, streams: Arc>>, + _client_close: Arc, } impl Client { @@ -45,6 +46,7 @@ impl Client { pub fn new(fd: RawFd) -> Client { let stream = utils::new_unix_stream_from_raw_fd(fd); + let client_close = Arc::new(ClientClose{fd}); let (req_tx, rx): (MessageSender, MessageReceiver) = mpsc::channel(100); let req_map = Arc::new(Mutex::new(HashMap::new())); @@ -60,6 +62,7 @@ impl Client { req_tx, next_stream_id: Arc::new(AtomicU32::new(1)), streams: req_map, + _client_close: client_close } } @@ -157,12 +160,10 @@ impl Client { struct ClientClose { fd: RawFd, - close_fd: RawFd, } impl Drop for ClientClose { fn drop(&mut self) { - close(self.close_fd).unwrap(); close(self.fd).unwrap(); trace!("All client is droped"); }