Skip to content

Commit 1646419

Browse files
use shared static mutex in pthread_mutex_lock test
Agent-Logs-Url: https://github.com/acl-dev/open-coroutine/sessions/a4199b83-4d02-43f6-aa5a-f79a5303135a Co-authored-by: loongs-zhang <38336731+loongs-zhang@users.noreply.github.com>
1 parent 889f7fe commit 1646419

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

core/tests/scheduler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,21 @@ fn scheduler_pthread_mutex_lock() -> std::io::Result<()> {
136136
use std::sync::atomic::{AtomicUsize, Ordering};
137137

138138
static COUNTER: AtomicUsize = AtomicUsize::new(0);
139+
static mut MUTEX: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER;
139140

140141
let mut scheduler = Scheduler::default();
141142
for _ in 0..3 {
142143
_ = scheduler.submit_co(
143144
|_, _| {
144-
let mut mutex = libc::PTHREAD_MUTEX_INITIALIZER;
145145
let r = open_coroutine_core::syscall::pthread_mutex_lock(
146146
None,
147-
std::ptr::addr_of_mut!(mutex),
147+
std::ptr::addr_of_mut!(MUTEX),
148148
);
149149
assert_eq!(0, r, "pthread_mutex_lock failed with {r}");
150150
COUNTER.fetch_add(1, Ordering::SeqCst);
151151
let r = open_coroutine_core::syscall::pthread_mutex_unlock(
152152
None,
153-
std::ptr::addr_of_mut!(mutex),
153+
std::ptr::addr_of_mut!(MUTEX),
154154
);
155155
assert_eq!(0, r, "pthread_mutex_unlock failed with {r}");
156156
None

0 commit comments

Comments
 (0)