From 2d4e76a680a65ea982812106a458db656529d8ec Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Thu, 7 Jun 2018 21:13:17 +0200 Subject: [PATCH] Haiku: Revert "std: Handle OS errors when joining threads" This reverts commit dc7c7ba0c9f401f5597a245e05ee9e8d760715d3. There is an issue with threading in cargo, where thread::join fails after completing a build. This prevents building Rust on Haiku (as the build system kills itself after failure). The problem is documented at rust-on-haiku.com issue #10 --- library/std/src/sys/unix/thread.rs | 2 +- library/std/src/sys/windows/c.rs | 1 - library/std/src/sys/windows/thread.rs | 5 +---- library/std/src/thread/mod.rs | 5 ----- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 04da9812ddc45..b2faa6b258de9 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -190,7 +190,7 @@ impl Thread { unsafe { let ret = libc::pthread_join(self.id, ptr::null_mut()); mem::forget(self); - assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret)); + debug_assert_eq!(ret, 0); } } diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index f440442ca3062..d6213f2ccb252 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -269,7 +269,6 @@ pub const FILE_END: DWORD = 2; pub const WAIT_OBJECT_0: DWORD = 0x00000000; pub const WAIT_TIMEOUT: DWORD = 258; -pub const WAIT_FAILED: DWORD = 0xFFFFFFFF; pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; diff --git a/library/std/src/sys/windows/thread.rs b/library/std/src/sys/windows/thread.rs index 38839ea5e90ed..7bb8c95d84d60 100644 --- a/library/std/src/sys/windows/thread.rs +++ b/library/std/src/sys/windows/thread.rs @@ -70,10 +70,7 @@ impl Thread { } pub fn join(self) { - let rc = unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE) }; - if rc == c::WAIT_FAILED { - panic!("failed to join on thread: {}", io::Error::last_os_error()); - } + unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE); } } pub fn yield_now() { diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 0b9849517c252..91eaf53d53cf7 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1423,11 +1423,6 @@ impl JoinHandle { /// [`Err`]: crate::result::Result::Err /// [atomic memory orderings]: crate::sync::atomic /// - /// # Panics - /// - /// This function may panic on some platforms if a thread attempts to join - /// itself or otherwise may create a deadlock with joining threads. - /// /// # Examples /// /// ```