If Close() exits due to cancellation/timeout and the mux is still running, subsequent calls to Close() will read from doneErr which will race with the mux.
Record closing state while synchronizing with the mux and cache the value so subsequent calls return the same value.
If Close() exits due to cancellation/timeout and the mux is still running, subsequent calls to Close() will read from doneErr which will race with the mux. Record closing state while synchronizing with the mux and cache the value so subsequent calls return the same value.
Example: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=2668077&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=bd05475d-acb5-5619-3ccb-c46842dbc997