-
Kirill Smelkov authored
While the second phase of select is running we queue send/recv cases to corresponding channels. At some point - when some of the cases are already queued - a peer goroutine might try to send/recv on that channel. And it will succeed because a waiter was queued to the channel. At the same time select is continuing its enqueue loop and before enqueuing to a channel it tries to send/recv there. If that channel became just ready (i.e. just after select poll phase) the try to send/recv will succeed. This means that actually 2 select cases could be executed at the same time. Fix it by carefully checking whether some case already won before trying to send/recv on a channel. This fixes the test failures that were demonstrated by previous 2 patches.
f0b592b4