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 Oct 16, 2020
1 parent 18bf6b4 commit 2d4e76a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
1 change: 0 additions & 1 deletion library/std/src/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;

pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
Expand Down
5 changes: 1 addition & 4 deletions library/std/src/sys/windows/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 0 additions & 5 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,11 +1423,6 @@ impl<T> JoinHandle<T> {
/// [`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
///
/// ```
Expand Down

0 comments on commit 2d4e76a

Please sign in to comment.