Skip to content

Commit aa18341

Browse files
committed
Fix join_mutex.
1 parent c44b489 commit aa18341

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/sys/unix/freertos/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ impl Thread {
2929
pub unsafe fn new(name: Option<&CStr>, stack: usize, p: Box<dyn FnOnce()>)
3030
-> io::Result<Thread> {
3131
let join_mutex = Arc::new(Mutex::new());
32-
join_mutex.lock();
3332
let state = Arc::new(AtomicUsize::new(RUNNING));
3433

3534
let arg = box (join_mutex.clone(), state.clone(), box p);
@@ -38,6 +37,7 @@ impl Thread {
3837

3938
let mut thread = Thread { id: ptr::null_mut(), join_mutex, state };
4039

40+
thread.join_mutex.lock();
4141

4242
let res = xTaskCreate(
4343
thread_start,
@@ -49,7 +49,7 @@ impl Thread {
4949
);
5050

5151
if res != pdTRUE {
52-
join_mutex.unlock();
52+
thread.join_mutex.unlock();
5353

5454
if res == errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY {
5555
return Err(io::Error::new(io::ErrorKind::Other, "could not allocate required memory for thread"));

0 commit comments

Comments
 (0)