add rdlock for find

Signed-off-by: qiyin.zhang <qiyin.zhang@ihuisen.com>
master
qiyin.zhang 2019-05-06 10:57:32 +08:00
parent 2b11efe1f9
commit 431359a96f
1 changed files with 2 additions and 0 deletions

View File

@ -95,7 +95,9 @@ int timer_del(MT_TIMER_OBJECT *object, int timerfd)
struct epoll_event event; struct epoll_event event;
MT_TIMER_NODE *handler = NULL; MT_TIMER_NODE *handler = NULL;
pthread_rwlock_rdlock(&object->timer_rwlock);
HASH_FIND_INT(object->timer_head, &timerfd, handler); HASH_FIND_INT(object->timer_head, &timerfd, handler);
pthread_rwlock_unlock(&object->timer_rwlock);
if(NULL == handler) if(NULL == handler)
return 0; return 0;