|
1 | 1 | //@compile-flags: -Zmiri-deterministic-concurrency |
2 | | -//~^ERROR: deadlocked |
3 | | -//~^^ERROR: deadlocked |
4 | 2 | //@only-target: linux android illumos |
5 | 3 | //@error-in-other-file: deadlock |
6 | 4 |
|
7 | 5 | use std::convert::TryInto; |
8 | | -use std::thread::spawn; |
| 6 | +use std::thread; |
9 | 7 |
|
10 | 8 | // Using `as` cast since `EPOLLET` wraps around |
11 | 9 | const EPOLL_IN_OUT_ET: u32 = (libc::EPOLLIN | libc::EPOLLOUT | libc::EPOLLET) as _; |
@@ -66,22 +64,21 @@ fn main() { |
66 | 64 |
|
67 | 65 | let expected_event = u32::try_from(libc::EPOLLIN | libc::EPOLLOUT).unwrap(); |
68 | 66 | let expected_value = fds[0] as u64; |
69 | | - let thread1 = spawn(move || { |
| 67 | + let thread1 = thread::spawn(move || { |
70 | 68 | check_epoll_wait::<1>(epfd, &[(expected_event, expected_value)], -1); |
71 | | - //~^ERROR: deadlocked |
72 | 69 | }); |
73 | | - let thread2 = spawn(move || { |
| 70 | + let thread2 = thread::spawn(move || { |
74 | 71 | check_epoll_wait::<1>(epfd, &[(expected_event, expected_value)], -1); |
| 72 | + //~^ERROR: deadlocked |
75 | 73 | }); |
| 74 | + // Yield so the threads are both blocked. |
| 75 | + thread::yield_now(); |
76 | 76 |
|
77 | | - let thread3 = spawn(move || { |
78 | | - // Just a single write, so we only wake up one of them. |
79 | | - let data = "abcde".as_bytes().as_ptr(); |
80 | | - let res = unsafe { libc::write(fds[1], data as *const libc::c_void, 5) }; |
81 | | - assert!(res > 0 && res <= 5); |
82 | | - }); |
| 77 | + // Just a single write, so we only wake up one of them. |
| 78 | + let data = "abcde".as_bytes().as_ptr(); |
| 79 | + let res = unsafe { libc::write(fds[1], data as *const libc::c_void, 5) }; |
| 80 | + assert!(res > 0 && res <= 5); |
83 | 81 |
|
84 | 82 | thread1.join().unwrap(); |
85 | 83 | thread2.join().unwrap(); |
86 | | - thread3.join().unwrap(); |
87 | 84 | } |
0 commit comments