From 01a224425d2a90e660bbfffe8d1cbc6b93da24bd Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 27 Jan 2025 16:56:15 -0500 Subject: Fix some rust race conditions and comment some likely suspects FYI The binary view saving stuff can deadlock right now, so we document that now :/ --- rust/src/collaboration/remote.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'rust/src/collaboration') diff --git a/rust/src/collaboration/remote.rs b/rust/src/collaboration/remote.rs index 382d1ca2..21f148e9 100644 --- a/rust/src/collaboration/remote.rs +++ b/rust/src/collaboration/remote.rs @@ -192,6 +192,10 @@ impl Remote { /// Connects to the Remote, loading metadata and optionally acquiring a token. /// /// Use [Remote::connect_with_opts] if you cannot otherwise automatically connect using enterprise. + /// + /// WARNING: This is currently **not** thread safe, if you try and connect/disconnect to a remote on + /// multiple threads you will be subject to race conditions. To avoid this wrap the [`Remote`] in + /// a synchronization primitive, and pass that to your threads. Or don't try and connect on multiple threads. pub fn connect(&self) -> Result<(), ()> { // TODO: implement SecretsProvider if self.is_enterprise()? && enterprise::is_server_authenticated() { @@ -234,6 +238,10 @@ impl Remote { } /// Disconnects from the remote. + /// + /// WARNING: This is currently **not** thread safe, if you try and connect/disconnect to a remote on + /// multiple threads you will be subject to race conditions. To avoid this wrap the [`Remote`] in + /// a synchronization primitive, and pass that to your threads. Or don't try and connect on multiple threads. pub fn disconnect(&self) -> Result<(), ()> { let success = unsafe { BNRemoteDisconnect(self.handle.as_ptr()) }; success.then_some(()).ok_or(()) -- cgit v1.3.1