Skip to content

Commit

Permalink
use recursive mutexes in handle-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
i-rinat committed Feb 21, 2016
1 parent 4f86b00 commit 7a297df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/handle-storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ handle_initialize_storage(void)
int
handle_insert(void *data)
{
int id;
pthread_mutexattr_t mattr;
pthread_mutexattr_init(&mattr);
pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);

VdpGenericData *gh = data;
pthread_mutex_init(&gh->lock, &mattr);
pthread_mutexattr_destroy(&mattr);

pthread_mutex_lock(&lock);
while (g_hash_table_lookup(vdp_handles, GINT_TO_POINTER(next_handle_id)))
next_handle_id ++;

id = next_handle_id ++;
int id = next_handle_id ++;
g_hash_table_insert(vdp_handles, GINT_TO_POINTER(id), data);

pthread_mutex_unlock(&lock);
Expand Down

0 comments on commit 7a297df

Please sign in to comment.