未验证 提交 d91b37b7 编写于 作者: S slguan 提交者: GitHub

Merge pull request #1478 from taosdata/hotfix/queue

Hotfix/queue
...@@ -68,10 +68,10 @@ void taosCloseQueue(taos_queue param) { ...@@ -68,10 +68,10 @@ void taosCloseQueue(taos_queue param) {
STaosQnode *pNode = queue->head; STaosQnode *pNode = queue->head;
queue->head = NULL; queue->head = NULL;
pthread_mutex_lock(&queue->mutex);
if (queue->qset) taosRemoveFromQset(queue->qset, queue); if (queue->qset) taosRemoveFromQset(queue->qset, queue);
pthread_mutex_lock(&queue->mutex);
while (pNode) { while (pNode) {
pTemp = pNode; pTemp = pNode;
pNode = pNode->next; pNode = pNode->next;
...@@ -253,33 +253,37 @@ void taosRemoveFromQset(taos_qset p1, taos_queue p2) { ...@@ -253,33 +253,37 @@ void taosRemoveFromQset(taos_qset p1, taos_queue p2) {
STaosQueue *queue = (STaosQueue *)p2; STaosQueue *queue = (STaosQueue *)p2;
STaosQset *qset = (STaosQset *)p1; STaosQset *qset = (STaosQset *)p1;
STaosQueue *tqueue; STaosQueue *tqueue = NULL;
pthread_mutex_lock(&qset->mutex); pthread_mutex_lock(&qset->mutex);
if (qset->head) { if (qset->head) {
if (qset->head == queue) { if (qset->head == queue) {
qset->head = qset->head->next; qset->head = qset->head->next;
qset->numOfQueues--; tqueue = queue;
} else { } else {
STaosQueue *prev = qset->head; STaosQueue *prev = qset->head;
tqueue = qset->head->next; tqueue = qset->head->next;
while (tqueue) { while (tqueue) {
if (tqueue== queue) { if (tqueue== queue) {
prev->next = tqueue->next; prev->next = tqueue->next;
if (qset->current == queue) qset->current = tqueue->next; break;
qset->numOfQueues--;
pthread_mutex_lock(&queue->mutex);
atomic_sub_fetch_32(&qset->numOfItems, queue->numOfItems);
queue->qset = NULL;
pthread_mutex_unlock(&queue->mutex);
} else { } else {
prev = tqueue; prev = tqueue;
tqueue = tqueue->next; tqueue = tqueue->next;
} }
} }
} }
if (tqueue) {
if (qset->current == queue) qset->current = tqueue->next;
qset->numOfQueues--;
pthread_mutex_lock(&queue->mutex);
atomic_sub_fetch_32(&qset->numOfItems, queue->numOfItems);
queue->qset = NULL;
pthread_mutex_unlock(&queue->mutex);
}
} }
pthread_mutex_unlock(&qset->mutex); pthread_mutex_unlock(&qset->mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册