static GSList *prof_handle_list = NULL;
static GHashTable *profile_cb_table = NULL;
static pthread_mutex_t g_conn_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __thread int g_conn_thread_mutex_ref = 0;
struct _profile_cb_s {
connection_profile_state_changed_cb callback;
void _connection_lock(void)
{
- pthread_mutex_lock(&g_conn_thread_mutex);
+ if (g_conn_thread_mutex_ref == 0)
+ pthread_mutex_lock(&g_conn_thread_mutex);
+
+ g_conn_thread_mutex_ref++;
}
void _connection_unlock(void)
{
- pthread_mutex_unlock(&g_conn_thread_mutex);
+ if (g_conn_thread_mutex_ref == 1)
+ pthread_mutex_unlock(&g_conn_thread_mutex);
+
+ g_conn_thread_mutex_ref--;
+
+//LCOV_EXCL_START
+ if (g_conn_thread_mutex_ref < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Error scenario, thread specific mutex ref is negative !!!");
+ g_conn_thread_mutex_ref = 0;
+ }
+//LCOV_EXCL_STOP
}