Commit d54924a
authored
* fix `Pollable` impl for `OutgoingDatagramStream`
Previously, `OutgoingDatagramStream` used its `send_state` field to determine
whether the socket was ready for writing without necessarily polling the
`tokio::net::UdpSocket`. The underlying assumption was that a freshly-bound
socket would be immediately ready for writing, but that's not true for `tokio`.
`tokio` assumes a socket is not ready for _anything_ by default and relies on
e.g. `epoll` to tell it otherwise.
In practice, this meant the `Pollable::ready` impl for `OutgoingDatagramStream`
would resolve immediately for a fresh socket, leaving the guest to race with
`tokio`'s use of `epoll`. Usually, `tokio` won and all was well, but
occasionally it lost and the `OutgoingDatagramStream::send` call would return
`Ok(0)` (meaning "would block") leaving the guest confused since it was just
told that the socket was ready for writing.
This commit removes `SendState` entirely, relying exclusively on
`tokio::net::UdpSocket::ready` for the `Pollable` and `check_send`
implementations. As a side effect, we no longer attempt to prevent the guest
from sending more datagrams than `check_send` indicated since the number
returned by `check_send` is only a guess anyway, and `tokio` will push back if
it needs to. For `p3`, the whole `check_send`/`send` pattern is gone, so we
won't need to concern ourselves with it going forward.
Fixes #12612
* address review feedback
1 parent 3621d3e commit d54924a
4 files changed
Lines changed: 76 additions & 59 deletions
File tree
- crates
- test-programs/src/bin
- wasi/src/p2
- host
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
120 | 144 | | |
121 | 145 | | |
122 | 146 | | |
| |||
136 | 160 | | |
137 | 161 | | |
138 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
139 | 170 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
169 | 183 | | |
170 | 184 | | |
| 185 | + | |
| 186 | + | |
171 | 187 | | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
175 | 191 | | |
176 | 192 | | |
177 | 193 | | |
| 194 | + | |
178 | 195 | | |
179 | | - | |
| 196 | + | |
180 | 197 | | |
181 | 198 | | |
182 | 199 | | |
183 | 200 | | |
184 | 201 | | |
185 | 202 | | |
186 | 203 | | |
| 204 | + | |
187 | 205 | | |
188 | 206 | | |
| 207 | + | |
189 | 208 | | |
190 | 209 | | |
191 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
255 | | - | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
278 | 281 | | |
279 | 282 | | |
280 | 283 | | |
| |||
324 | 327 | | |
325 | 328 | | |
326 | 329 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | 330 | | |
344 | 331 | | |
345 | 332 | | |
| |||
354 | 341 | | |
355 | 342 | | |
356 | 343 | | |
357 | | - | |
358 | | - | |
| 344 | + | |
| 345 | + | |
359 | 346 | | |
360 | 347 | | |
361 | 348 | | |
| |||
386 | 373 | | |
387 | 374 | | |
388 | 375 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
400 | 380 | | |
401 | 381 | | |
402 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
0 commit comments