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 Jan 30, 2020
1 parent 5e1a799 commit d0204dc
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,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 @@ -254,7 +254,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 src/libstd/sys/windows/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,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 @@ -1447,11 +1447,6 @@ impl<T> JoinHandle<T> {
/// [`panic`]: ../../std/macro.panic.html
/// [atomic memory orderings]: ../../std/sync/atomic/index.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 d0204dc

Please sign in to comment.