@@ -662,13 +662,12 @@ fn cross_process_server()
662662{
663663 let data: & [ u8 ] = b"1234567" ;
664664 let channel_name = get_channel_name_arg ( "server" ) ;
665- if channel_name . is_none ( ) {
666- return ;
667- }
665+ if let Some ( channel_name ) = channel_name {
666+ let tx = OsIpcSender :: connect ( channel_name ) . unwrap ( ) ;
667+ tx . send ( data , vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
668668
669- let tx = OsIpcSender :: connect ( channel_name. unwrap ( ) ) . unwrap ( ) ;
670- tx. send ( data, vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
671- unsafe { libc:: exit ( 0 ) ; }
669+ unsafe { libc:: exit ( 0 ) ; }
670+ }
672671}
673672
674673#[ cfg( not( any( feature = "force-inprocess" , target_os = "windows" , target_os = "android" ) ) ) ]
@@ -721,18 +720,17 @@ fn cross_process_fork() {
721720fn cross_process_sender_transfer_server ( )
722721{
723722 let channel_name = get_channel_name_arg ( "server" ) ;
724- if channel_name. is_none ( ) {
725- return ;
726- }
723+ if let Some ( channel_name) = channel_name {
724+ let super_tx = OsIpcSender :: connect ( channel_name) . unwrap ( ) ;
725+ let ( sub_tx, sub_rx) = platform:: channel ( ) . unwrap ( ) ;
726+ let data: & [ u8 ] = b"foo" ;
727+ super_tx. send ( data, vec ! [ OsIpcChannel :: Sender ( sub_tx) ] , vec ! [ ] ) . unwrap ( ) ;
728+ sub_rx. recv ( ) . unwrap ( ) ;
729+ let data: & [ u8 ] = b"bar" ;
730+ super_tx. send ( data, vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
727731
728- let super_tx = OsIpcSender :: connect ( channel_name. unwrap ( ) ) . unwrap ( ) ;
729- let ( sub_tx, sub_rx) = platform:: channel ( ) . unwrap ( ) ;
730- let data: & [ u8 ] = b"foo" ;
731- super_tx. send ( data, vec ! [ OsIpcChannel :: Sender ( sub_tx) ] , vec ! [ ] ) . unwrap ( ) ;
732- sub_rx. recv ( ) . unwrap ( ) ;
733- let data: & [ u8 ] = b"bar" ;
734- super_tx. send ( data, vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
735- unsafe { libc:: exit ( 0 ) ; }
732+ unsafe { libc:: exit ( 0 ) ; }
733+ }
736734}
737735
738736#[ cfg( not( any( feature = "force-inprocess" , target_os = "windows" , target_os = "android" ) ) ) ]
@@ -968,38 +966,36 @@ fn cross_process_two_step_transfer_server()
968966{
969967 let cookie: & [ u8 ] = b"cookie" ;
970968 let channel_name = get_channel_name_arg ( "server" ) ;
971- if channel_name. is_none ( ) {
972- return ;
973- }
974-
975- // connect by name to our other process
976- let super_tx = OsIpcSender :: connect ( channel_name. unwrap ( ) ) . unwrap ( ) ;
969+ if let Some ( channel_name) = channel_name {
970+ // connect by name to our other process
971+ let super_tx = OsIpcSender :: connect ( channel_name) . unwrap ( ) ;
977972
978- // create a channel for real communication between the two processes
979- let ( sub_tx, sub_rx) = platform:: channel ( ) . unwrap ( ) ;
973+ // create a channel for real communication between the two processes
974+ let ( sub_tx, sub_rx) = platform:: channel ( ) . unwrap ( ) ;
980975
981- // send the other process the tx side, so it can send us the channels
982- super_tx. send ( & [ ] , vec ! [ OsIpcChannel :: Sender ( sub_tx) ] , vec ! [ ] ) . unwrap ( ) ;
976+ // send the other process the tx side, so it can send us the channels
977+ super_tx. send ( & [ ] , vec ! [ OsIpcChannel :: Sender ( sub_tx) ] , vec ! [ ] ) . unwrap ( ) ;
983978
984- // get two_rx from the other process
985- let ( _, mut received_channels, _) = sub_rx. recv ( ) . unwrap ( ) ;
986- assert_eq ! ( received_channels. len( ) , 1 ) ;
987- let two_rx = received_channels[ 0 ] . to_receiver ( ) ;
979+ // get two_rx from the other process
980+ let ( _, mut received_channels, _) = sub_rx. recv ( ) . unwrap ( ) ;
981+ assert_eq ! ( received_channels. len( ) , 1 ) ;
982+ let two_rx = received_channels[ 0 ] . to_receiver ( ) ;
988983
989- // get one_rx from two_rx's buffer
990- let ( _, mut received_channels, _) = two_rx. recv ( ) . unwrap ( ) ;
991- assert_eq ! ( received_channels. len( ) , 1 ) ;
992- let one_rx = received_channels[ 0 ] . to_receiver ( ) ;
984+ // get one_rx from two_rx's buffer
985+ let ( _, mut received_channels, _) = two_rx. recv ( ) . unwrap ( ) ;
986+ assert_eq ! ( received_channels. len( ) , 1 ) ;
987+ let one_rx = received_channels[ 0 ] . to_receiver ( ) ;
993988
994- // get a cookie from one_rx
995- let ( data, _, _) = one_rx. recv ( ) . unwrap ( ) ;
996- assert_eq ! ( & data[ ..] , cookie) ;
989+ // get a cookie from one_rx
990+ let ( data, _, _) = one_rx. recv ( ) . unwrap ( ) ;
991+ assert_eq ! ( & data[ ..] , cookie) ;
997992
998- // finally, send a cookie back
999- super_tx. send ( & data, vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
993+ // finally, send a cookie back
994+ super_tx. send ( & data, vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
1000995
1001- // terminate
1002- unsafe { libc:: exit ( 0 ) ; }
996+ // terminate
997+ unsafe { libc:: exit ( 0 ) ; }
998+ }
1003999}
10041000
10051001// TODO -- this fails on OSX with a MACH_SEND_INVALID_RIGHT!
0 commit comments