mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
bugfix: read cap in lock
This commit is contained in:
@@ -111,16 +111,18 @@ skynet_mq_handle(struct message_queue *q) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
skynet_mq_length(struct message_queue *q) {
|
skynet_mq_length(struct message_queue *q) {
|
||||||
int head, tail;
|
int head, tail,cap;
|
||||||
|
|
||||||
LOCK(q)
|
LOCK(q)
|
||||||
head = q->head;
|
head = q->head;
|
||||||
tail = q->tail;
|
tail = q->tail;
|
||||||
|
cap = q->cap;
|
||||||
UNLOCK(q)
|
UNLOCK(q)
|
||||||
|
|
||||||
if (head <= tail) {
|
if (head <= tail) {
|
||||||
return tail - head;
|
return tail - head;
|
||||||
}
|
}
|
||||||
return tail + q->cap - head;
|
return tail + cap - head;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
Reference in New Issue
Block a user