Commit b27a2d9
JSON-RPC: fix connect/disconnect crash, consolidate connection notifications
Three related changes to the client connection RPC introduced by this PR:
1. Crash fix. CClient::Stop() ran the event loop (QCoreApplication::processEvents)
for its 100 ms settle. Called from the connect/disconnect handlers, that
re-entered the JSON-RPC readyRead handler while it was still on the stack and
freed a socket that was then written to: a use-after-free (stack overflow under
overlapping requests). Keep the settle but do it with QThread::msleep, so no
events are pumped and no re-entrancy is possible. Verified with AddressSanitizer
on Linux and macOS: overlapping connect/disconnect plus 8-thread churn crash
before this change and are clean after; a plain deferral and a re-entrancy guard
were each insufficient.
2. Consolidate notifications. Fold jamulusclient/connecting and
jamulusclient/connectingFailed into jamulusclient/connectionStateChanged, which
now carries serverName and, on a failed attempt, error (serverName is omitted
there, since an invalid address fails before the name is set). One notification
follows the whole lifecycle; connected/disconnected are unchanged.
3. Rename jamulusclient/connect to jamulusclient/requestConnection: it returns "ok"
as soon as the attempt is initiated, not when it succeeds, so the name reflects a
request. Reads symmetrically with getConnectionState.
docs/JSON-RPC.md regenerated.
CHANGELOG: fix a client crash when connect/disconnect are driven over JSON-RPC
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PEyPQdxy6h7vQtUDCh2KY21 parent a474d52 commit b27a2d9
3 files changed
Lines changed: 53 additions & 78 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 132 | | |
151 | 133 | | |
152 | 134 | | |
| |||
309 | 291 | | |
310 | 292 | | |
311 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| |||
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | 712 | | |
735 | 713 | | |
736 | | - | |
| 714 | + | |
737 | 715 | | |
738 | 716 | | |
739 | 717 | | |
740 | 718 | | |
741 | 719 | | |
742 | 720 | | |
| 721 | + | |
| 722 | + | |
743 | 723 | | |
744 | 724 | | |
745 | 725 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
1108 | 1109 | | |
1109 | 1110 | | |
1110 | 1111 | | |
1111 | | - | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
1124 | 1118 | | |
1125 | 1119 | | |
1126 | 1120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
199 | 189 | | |
200 | | - | |
| 190 | + | |
201 | 191 | | |
| 192 | + | |
202 | 193 | | |
203 | 194 | | |
204 | 195 | | |
205 | 196 | | |
206 | 197 | | |
207 | | - | |
| 198 | + | |
| 199 | + | |
208 | 200 | | |
| 201 | + | |
| 202 | + | |
209 | 203 | | |
210 | 204 | | |
211 | 205 | | |
212 | 206 | | |
| 207 | + | |
213 | 208 | | |
214 | 209 | | |
215 | 210 | | |
| |||
257 | 252 | | |
258 | 253 | | |
259 | 254 | | |
260 | | - | |
| 255 | + | |
261 | 256 | | |
262 | | - | |
263 | | - | |
264 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
265 | 260 | | |
266 | | - | |
| 261 | + | |
267 | 262 | | |
268 | | - | |
| 263 | + | |
269 | 264 | | |
270 | 265 | | |
271 | 266 | | |
272 | 267 | | |
273 | 268 | | |
274 | 269 | | |
275 | 270 | | |
276 | | - | |
277 | | - | |
278 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| |||
0 commit comments