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

porting/linux: fix deadlock in ble_npl_hw_enter_critical #1607

Merged
merged 1 commit into from
Sep 20, 2023
Merged
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
8 changes: 4 additions & 4 deletions porting/npl/linux/src/os_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@

#include "nimble/nimble_npl.h"

static pthread_mutex_t s_mutex = PTHREAD_MUTEX_INITIALIZER;
static struct ble_npl_mutex s_mutex;
static uint8_t s_mutex_inited = 0;

uint32_t ble_npl_hw_enter_critical(void)
{
if( !s_mutex_inited ) {
pthread_mutexattr_settype(&s_mutex, PTHREAD_MUTEX_RECURSIVE);
ble_npl_mutex_init(&s_mutex);
s_mutex_inited = 1;
}

pthread_mutex_lock(&s_mutex);
pthread_mutex_lock(&s_mutex.lock);
return 0;
}

void ble_npl_hw_exit_critical(uint32_t ctx)
{
pthread_mutex_unlock(&s_mutex);
pthread_mutex_unlock(&s_mutex.lock);
}
Loading