fmsg: add to wg prior to enqueue
All checks were successful
test / test (push) Successful in 27s

Adding after channel write is racy.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
Ophestra 2024-11-17 23:50:02 +09:00
parent c1fad649e8
commit 866270ff05
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -33,16 +33,17 @@ func dequeue() {
// queue submits ops to msgbuf but drops messages
// when the buffer is full and dequeue is withholding
func queue(op dOp) {
queueSync.Add(1)
select {
case msgbuf <- op:
queueSync.Add(1)
default:
// send the op anyway if not withholding
// as dequeue will get to it eventually
if !wstate.Load() {
queueSync.Add(1)
msgbuf <- op
} else {
queueSync.Done()
// increment dropped message count
dropped.Add(1)
}