Skip to content

Commit

Permalink
📝 return write error
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang committed Mar 1, 2024
1 parent c324118 commit 4cbaf7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/conetty/multiplex_client.rs
Expand Up @@ -95,7 +95,7 @@ impl<S: StreamExt> Client for MultiplexClient<S> {
let id: usize = id.into();
let buf = req.finish(id as u64);

self.sock.write(buf);
self.sock.write(buf)?;

// wait for the rsp
Ok(waiter.wait_rsp(self.timeout)?)
Expand Down
8 changes: 3 additions & 5 deletions src/conetty/queued_writer.rs
Expand Up @@ -49,7 +49,7 @@ impl<W: Write> QueuedWriter<W> {
}

/// it's safe and efficient to call this API concurrently
pub fn write(&self, data: Vec<u8>) {
pub fn write(&self, data: Vec<u8>) -> std::io::Result<()> {
self.data_queue.push(data);
// only allow the first writer perform the write operation
// other concurrent writers would just push the data
Expand All @@ -70,10 +70,8 @@ impl<W: Write> QueuedWriter<W> {
}
}

if let Err(e) = writer.write_all() {
// FIXME: handle the error
error!("QueuedWriter failed, err={}", e);
}
writer.write_all()?;
}
Ok(())
}
}
4 changes: 2 additions & 2 deletions src/conetty/server.rs
Expand Up @@ -141,7 +141,7 @@ pub trait TcpServer: Server {

info!("send rsp: id={}", req.id);
// send the result back to client
w_stream.write(data);
w_stream.write(data).expect("tcp write to client failed");
});
}
});
Expand Down Expand Up @@ -206,7 +206,7 @@ pub trait UdsServer: Server {

info!("send rsp: id={}", req.id);
// send the result back to client
w_stream.write(data);
w_stream.write(data).expect("uds write to client failed");
});
}
});
Expand Down

0 comments on commit 4cbaf7e

Please sign in to comment.