Repository navigation
Commit da90652
system/gdbstub: Serve the next client when a TCP client closes.
With "gdbstub -p <port>", a client that closes the connection stopped
the server:
- read() returns 0 when the peer closed, and gdb_recv() called it again
forever without blocking. gdbstub kept the CPU busy and never
accepted another client. This happens on the gdb command
"disconnect" or when gdb is killed (gdb sends "k" first only when
it exits normally).
- An error other than ECONNRESET from gdb_process() ended gdbstub.
- A write to the closed socket can raise SIGPIPE, which ends gdbstub
when the default action of SIGPIPE terminates the task.
- Each new client allocated a new gdb state; the old one leaked.
gdb_recv() now returns -ECONNRESET at end of file, as the stub does on a
"k" packet. In TCP mode, any error from gdb_process() ends the session:
gdbstub frees the state, closes the connection and accepts the next
client. The TCP mode sends with send(MSG_NOSIGNAL). The tty mode does
not change.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>1 parent 09a59b9 commit da90652
1 file changed
Lines changed: 45 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
95 | 117 | | |
96 | 118 | | |
97 | 119 | | |
| |||
106 | 128 | | |
107 | 129 | | |
108 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
109 | 135 | | |
110 | 136 | | |
111 | 137 | | |
| |||
215 | 241 | | |
216 | 242 | | |
217 | 243 | | |
218 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
219 | 255 | | |
220 | 256 | | |
221 | 257 | | |
| |||
225 | 261 | | |
226 | 262 | | |
227 | 263 | | |
228 | | - | |
229 | | - | |
230 | 264 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
236 | 268 | | |
237 | | - | |
238 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
239 | 272 | | |
| 273 | + | |
240 | 274 | | |
241 | 275 | | |
242 | 276 | | |
| |||
0 commit comments