Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the error from pthread_mutex_lock in lock_thread #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions user_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,16 @@ static THREAD_MUTEX_T dmalloc_mutex;
/*
* mutex lock the malloc library
*/
static void lock_thread(void)
static int lock_thread(void)
{
/* we only lock if the lock-on counter has reached 0 */
if (thread_lock_c == 0) {
#if HAVE_PTHREAD_MUTEX_LOCK
pthread_mutex_lock(&dmalloc_mutex);
return pthread_mutex_lock(&dmalloc_mutex) == 0;
#endif
}

return 1;
}

/*
Expand Down Expand Up @@ -483,7 +485,9 @@ static int dmalloc_in(const char *file, const int line,
}

#if LOCK_THREADS
lock_thread();
if (! lock_thread()) {
return 0;
}
#endif

if (in_alloc_b) {
Expand Down