Adding after channel write is racy. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
c1fad649e8
commit
866270ff05
@ -33,16 +33,17 @@ func dequeue() {
|
|||||||
// queue submits ops to msgbuf but drops messages
|
// queue submits ops to msgbuf but drops messages
|
||||||
// when the buffer is full and dequeue is withholding
|
// when the buffer is full and dequeue is withholding
|
||||||
func queue(op dOp) {
|
func queue(op dOp) {
|
||||||
|
queueSync.Add(1)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case msgbuf <- op:
|
case msgbuf <- op:
|
||||||
queueSync.Add(1)
|
|
||||||
default:
|
default:
|
||||||
// send the op anyway if not withholding
|
// send the op anyway if not withholding
|
||||||
// as dequeue will get to it eventually
|
// as dequeue will get to it eventually
|
||||||
if !wstate.Load() {
|
if !wstate.Load() {
|
||||||
queueSync.Add(1)
|
|
||||||
msgbuf <- op
|
msgbuf <- op
|
||||||
} else {
|
} else {
|
||||||
|
queueSync.Done()
|
||||||
// increment dropped message count
|
// increment dropped message count
|
||||||
dropped.Add(1)
|
dropped.Add(1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user