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 {
5555 #[ cfg( unix) ]
5656 /// Initialize a new [`Client`] from raw file descriptor.
5757 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" ) ) ?;
5960
6061 Self :: new_client ( conn)
6162 }
Original file line number Diff line number Diff line change @@ -228,14 +228,14 @@ pub struct ClientConnection {
228228}
229229
230230impl ClientConnection {
231- pub fn client_connect ( sockaddr : & str ) -> Result < ClientConnection > {
231+ pub fn client_connect ( sockaddr : & str ) -> Result < ClientConnection > {
232232 let fd = unsafe { client_connect ( sockaddr) ? } ;
233- Ok ( ClientConnection :: new ( fd) )
233+ ClientConnection :: new ( fd)
234234 }
235235
236- pub ( crate ) fn new ( fd : RawFd ) -> ClientConnection {
236+ pub ( crate ) fn new ( fd : RawFd ) -> Result < ClientConnection > {
237237 let ( recver_fd, close_fd) =
238- socketpair ( AddressFamily :: Unix , SockType :: Stream , None , SOCK_CLOEXEC ) . unwrap ( ) ;
238+ socketpair ( AddressFamily :: Unix , SockType :: Stream , None , SOCK_CLOEXEC ) ? ;
239239
240240 // MacOS doesn't support descriptor creation with SOCK_CLOEXEC automically,
241241 // so there is a chance of leak if fork + exec happens in between of these calls.
@@ -245,11 +245,10 @@ impl ClientConnection {
245245 set_fd_close_exec ( close_fd) . unwrap ( ) ;
246246 }
247247
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+ } )
253252 }
254253
255254 pub fn ready ( & self ) -> std:: result:: Result < Option < ( ) > , io:: Error > {
You can’t perform that action at this time.
0 commit comments