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