diff options
Diffstat (limited to 'btif/src/btif_sock_thread.c')
-rw-r--r-- | btif/src/btif_sock_thread.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/btif/src/btif_sock_thread.c b/btif/src/btif_sock_thread.c index b0946ec..71cf5db 100644 --- a/btif/src/btif_sock_thread.c +++ b/btif/src/btif_sock_thread.c @@ -109,8 +109,7 @@ static inline void close_cmd_fd(int h); static inline void add_poll(int h, int fd, int type, int flags, uint32_t user_id); -static pthread_mutex_t thread_slot_lock; - +static pthread_mutex_t thread_slot_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static inline pthread_t create_thread(void *(*start_routine)(void *), void * arg) { @@ -158,7 +157,6 @@ int btsock_thread_init() if(!initialized) { initialized = 1; - init_slot_lock(&thread_slot_lock); int h; for(h = 0; h < MAX_THREAD; h++) { @@ -175,9 +173,9 @@ int btsock_thread_init() int btsock_thread_create(btsock_signaled_cb callback, btsock_cmd_cb cmd_callback) { asrt(callback || cmd_callback); - lock_slot(&thread_slot_lock); + pthread_mutex_lock(&thread_slot_lock); int h = alloc_thread_slot(); - unlock_slot(&thread_slot_lock); + pthread_mutex_unlock(&thread_slot_lock); APPL_TRACE_DEBUG("alloc_thread_slot ret:%d", h); if(h >= 0) { @@ -323,9 +321,9 @@ int btsock_thread_exit(int h) if(send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0) == sizeof(cmd)) { pthread_join(ts[h].thread_id, 0); - lock_slot(&thread_slot_lock); + pthread_mutex_lock(&thread_slot_lock); free_thread_slot(h); - unlock_slot(&thread_slot_lock); + pthread_mutex_unlock(&thread_slot_lock); return TRUE; } return FALSE; |