Skip to content

Commit

Permalink
Haiku: Revert "std: Handle OS errors when joining threads"
Browse files Browse the repository at this point in the history
This reverts commit dc7c7ba.

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
  • Loading branch information
nielx committed Jun 22, 2018
1 parent 02cd183 commit 9bb7ba3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/libstd/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,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);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/libstd/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

#[cfg(target_env = "msvc")]
#[cfg(feature = "backtrace")]
Expand Down
6 changes: 1 addition & 5 deletions src/libstd/sys/windows/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,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() {
Expand Down
5 changes: 0 additions & 5 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,11 +1303,6 @@ impl<T> JoinHandle<T> {
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
/// [`panic`]: ../../std/macro.panic.html
///
/// # 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
///
/// ```
Expand Down

0 comments on commit 9bb7ba3

Please sign in to comment.