Commit 1babe1d
authored
IXWebSocketTransport::setReadyState(): Run under lock (#540)
When setReadyState(CLOSED) is executed from two different threads (the
server's thread, detecting a close trying to receive and a separate
sending thread), there is a race where both see _readyState as non-CLOSED
and both execute the _onCloseCallback(). Worse, the server's thread might
be returning from ->run(), unsetting the callback while the other thread
is still about to call the _onCloseCallback(), resulting in a crash
rather than "just" a duplicate invocation of the callback.
This change ensures that setReadyState() *and* the_onCloseCallback()
are executed by a single thread till completion, by introducing a new
_setReadyStateMutex instance held during setReadyState() execution.1 parent 8115594 commit 1babe1d
2 files changed
+8
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
208 | 214 | | |
209 | 215 | | |
210 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| |||
0 commit comments