Skip to content

Commit

Permalink
Make Linux critical section recursive, same as Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
Meridian59 committed Jan 7, 2016
1 parent 90920b4 commit cbb005b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion blakserv/critical_section.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

void InitializeCriticalSection(CRITICAL_SECTION *m)
{
pthread_mutex_init(m, NULL);
// Make the mutex reentrant, the same way a Windows critical
// section is.
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);

pthread_mutex_init(m, &attr);
}

void EnterCriticalSection(CRITICAL_SECTION *m)
Expand Down

0 comments on commit cbb005b

Please sign in to comment.