Fixed Panic when “peer Close & local user Close” occurs simultaneously
Fixed concurrency issues in extreme scenarios.
Scenario: “peer Close & local user Close” occurs at the same time, and
lock(user), and Poller also executes
p.detaches (all three conditions are met)
When two goroutines execute
op.Control(PollDetach) at the same time,
op.unused will be executed twice.
When the program is idle, it is possible that
c.onclose has completed the
freeop has been reused, and the state becomes
That’s when the
p.detaches is executed; This will incorrectly set the operator of a new connection to 0, causing all subsequent
op.do to fail in an infinite loop.
Poller no longer executes
detach asynchronously to ensure that it does not run concurrently with
C.onclose and the changes are performance-neutral.