File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ impl Client {
55
55
#[ cfg( unix) ]
56
56
/// Initialize a new [`Client`] from raw file descriptor.
57
57
pub fn new ( fd : RawFd ) -> Result < Client > {
58
- let conn = ClientConnection :: new ( fd) ;
58
+ let conn =
59
+ ClientConnection :: new ( fd) . map_err ( err_to_others_err ! ( e, "new ClientConnection" ) ) ?;
59
60
60
61
Self :: new_client ( conn)
61
62
}
Original file line number Diff line number Diff line change @@ -228,14 +228,14 @@ pub struct ClientConnection {
228
228
}
229
229
230
230
impl ClientConnection {
231
- pub fn client_connect ( sockaddr : & str ) -> Result < ClientConnection > {
231
+ pub fn client_connect ( sockaddr : & str ) -> Result < ClientConnection > {
232
232
let fd = unsafe { client_connect ( sockaddr) ? } ;
233
- Ok ( ClientConnection :: new ( fd) )
233
+ ClientConnection :: new ( fd)
234
234
}
235
235
236
- pub ( crate ) fn new ( fd : RawFd ) -> ClientConnection {
236
+ pub ( crate ) fn new ( fd : RawFd ) -> Result < ClientConnection > {
237
237
let ( recver_fd, close_fd) =
238
- socketpair ( AddressFamily :: Unix , SockType :: Stream , None , SOCK_CLOEXEC ) . unwrap ( ) ;
238
+ socketpair ( AddressFamily :: Unix , SockType :: Stream , None , SOCK_CLOEXEC ) ? ;
239
239
240
240
// MacOS doesn't support descriptor creation with SOCK_CLOEXEC automically,
241
241
// so there is a chance of leak if fork + exec happens in between of these calls.
@@ -245,11 +245,10 @@ impl ClientConnection {
245
245
set_fd_close_exec ( close_fd) . unwrap ( ) ;
246
246
}
247
247
248
-
249
- ClientConnection {
250
- fd,
251
- socket_pair : ( recver_fd, close_fd)
252
- }
248
+ Ok ( ClientConnection {
249
+ fd,
250
+ socket_pair : ( recver_fd, close_fd) ,
251
+ } )
253
252
}
254
253
255
254
pub fn ready ( & self ) -> std:: result:: Result < Option < ( ) > , io:: Error > {
You can’t perform that action at this time.
0 commit comments