File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ func (c *Cond) Wait() {
5454
5555 // Temporarily unlock L.
5656 c .L .Unlock ()
57+
58+ // Re-acquire the lock before returning.
5759 defer c .L .Lock ()
5860
5961 // If we were signaled while unlocking, immediately complete.
@@ -62,16 +64,14 @@ func (c *Cond) Wait() {
6264 }
6365
6466 // Remove the earlySignal frame.
65- if c .unlocking == & early {
66- c .unlocking = early .next
67- } else {
68- // Something else happened after the unlock - the earlySignal is somewhere in the middle.
69- // This would be faster but less space-efficient if it were a doubly linked list.
70- prev := c .unlocking
71- for prev .next != & early {
72- prev = prev .next
73- }
67+ prev := c .unlocking
68+ for prev != nil && prev .next != & early {
69+ prev = prev .next
70+ }
71+ if prev != nil {
7472 prev .next = early .next
73+ } else {
74+ c .unlocking = early .next
7575 }
7676
7777 // Wait for a signal.
You can’t perform that action at this time.
0 commit comments