Commit 07d6409
committed
fix: suppress net.ErrClosed on concurrent Close
Close and CloseNow return net.ErrClosed when the read loop or
write path wins the casClosing race. The defer that suppresses
net.ErrClosed is only registered on the winner path, so the
user-facing call surfaces a wrapped "use of closed network
connection" even though the close succeeded.
Move the defer before the casClosing check so both paths
suppress net.ErrClosed, matching the godoc contract that
additional calls to Close are no-ops.1 parent d099e16 commit 07d6409
2 files changed
Lines changed: 10 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | 101 | | |
110 | 102 | | |
111 | 103 | | |
112 | 104 | | |
113 | 105 | | |
114 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
115 | 111 | | |
116 | 112 | | |
117 | 113 | | |
| |||
131 | 127 | | |
132 | 128 | | |
133 | 129 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | 130 | | |
143 | 131 | | |
144 | 132 | | |
145 | 133 | | |
146 | 134 | | |
147 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
148 | 140 | | |
149 | 141 | | |
150 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
401 | | - | |
| 400 | + | |
| 401 | + | |
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| |||
0 commit comments