Skip to content

Commit b336f73

Browse files
equeue posix impl: make queue mutex reentrant
1 parent 66da694 commit b336f73

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

UNITTESTS/stubs/EqueuePosix_stub.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ unsigned equeue_tick(void)
4040
// Mutex operations
4141
int equeue_mutex_create(equeue_mutex_t *m)
4242
{
43-
return pthread_mutex_init(m, 0);
43+
pthread_mutexattr_t attr;
44+
pthread_mutexattr_init(&attr);
45+
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
46+
return pthread_mutex_init(m, &attr);
4447
}
4548

4649
void equeue_mutex_destroy(equeue_mutex_t *m)

events/source/equeue_posix.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ unsigned equeue_tick(void)
4040
// Mutex operations
4141
int equeue_mutex_create(equeue_mutex_t *m)
4242
{
43-
return pthread_mutex_init(m, 0);
43+
pthread_mutexattr_t attr;
44+
pthread_mutexattr_init(&attr);
45+
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
46+
return pthread_mutex_init(m, &attr);
4447
}
4548

4649
void equeue_mutex_destroy(equeue_mutex_t *m)

0 commit comments

Comments
 (0)