File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -40,3 +40,5 @@ pub mod router;
4040mod test;
4141
4242pub use bincode:: { Error , ErrorKind } ;
43+ #[ cfg( all( not( feature = "force-inprocess" ) , target_os = "macos" ) ) ]
44+ pub use platform:: set_bootstrap_prefix;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ use std::mem;
2727use std:: ops:: Deref ;
2828use std:: ptr;
2929use std:: slice;
30- use std:: sync:: RwLock ;
30+ use std:: sync:: { OnceLock , RwLock } ;
3131use std:: time:: Duration ;
3232
3333mod mach_sys;
@@ -36,8 +36,14 @@ mod mach_sys;
3636/// this, we retry and spill to the heap.
3737const SMALL_MESSAGE_SIZE : usize = 4096 ;
3838
39+ pub fn set_bootstrap_prefix ( prefix : impl Into < String > ) {
40+ BOOTSTRAP_PREFIX
41+ . set ( prefix. into ( ) )
42+ . expect ( "set_bootstrap_prefix can only be called once" )
43+ }
44+
3945/// A string to prepend to our bootstrap ports.
40- static BOOTSTRAP_PREFIX : & str = "org.rust-lang.ipc-channel." ;
46+ pub ( crate ) static BOOTSTRAP_PREFIX : OnceLock < String > = OnceLock :: new ( ) ;
4147
4248const BOOTSTRAP_NAME_IN_USE : kern_return_t = 1101 ;
4349const BOOTSTRAP_SUCCESS : kern_return_t = 0 ;
@@ -265,7 +271,14 @@ impl OsIpcReceiver {
265271 let mut os_result;
266272 let mut name;
267273 loop {
268- name = format ! ( "{}{}" , BOOTSTRAP_PREFIX , rand:: rng( ) . random:: <i64 >( ) ) ;
274+ name = format ! (
275+ "{}{}" ,
276+ BOOTSTRAP_PREFIX
277+ . get( )
278+ . map( AsRef :: as_ref)
279+ . unwrap_or_else( || "org.rust-lang.ipc-channel." ) ,
280+ rand:: rng( ) . random:: <i64 >( )
281+ ) ;
269282 let c_name = CString :: new ( name. clone ( ) ) . unwrap ( ) ;
270283 os_result = bootstrap_register2 ( bootstrap_port, c_name. as_ptr ( ) , right, 0 ) ;
271284 if os_result == BOOTSTRAP_NAME_IN_USE {
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ mod macos;
3636mod os {
3737 pub use super :: macos:: * ;
3838}
39+ #[ cfg( all( not( feature = "force-inprocess" ) , target_os = "macos" ) ) ]
40+ pub use macos:: set_bootstrap_prefix;
3941
4042#[ cfg( all( not( feature = "force-inprocess" ) , target_os = "windows" ) ) ]
4143mod windows;
You can’t perform that action at this time.
0 commit comments