Commit 8b2d36b
authored
fix(netwatch): ignore transient recv errors (#166)
## Description
On Windows, `UdpSocket::recv` can return an error if the previous *send*
operation on that socket failed with an ICMP error.
The error either surfaces as `WSAECONNRESET`, which the Rust standard
library converts into a `io::ErrorKind::ConnectionReset`, or as a
`WSAENETRESET`, which becomes `ErrorKind::Uncategorized`.
`WSAECONNRESET` is emitted if the previous send failed due to a *ICMP
port unreachable*, and `WSAENETRESET` if the previous send got a TTL
expired (I think, not sure exactly).
Both of these errors are transient, because they are issued max. once
per sent datagram. The next recv on the socket then returns either a
datagram, a different error, or WouldBlock.
This PR changes the behavior such that we ignore these errors.
It comes with a regression test (first commit). I confirmed that it
fails on windows without the fix in the second commit.
Fixes n0-computer/iroh#4297
Fixes n0-computer/iroh-gossip#149
Also tested in n0-computer/iroh#4348
## Breaking Changes
None
## Notes & open questions
We can and likely should set the `SIO_UDP_CONNRESET` socket option on
the underlying socket, which supresses at least the `WSAECONNRESET`
error altogether. This would need to happen in `noq_udp` though. And
even if we did it, it's still better to also ignore these errors here
IMO.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.1 parent 59a1a38 commit 8b2d36b
1 file changed
Lines changed: 94 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
| |||
489 | 492 | | |
490 | 493 | | |
491 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
492 | 532 | | |
493 | 533 | | |
494 | 534 | | |
| |||
1121 | 1161 | | |
1122 | 1162 | | |
1123 | 1163 | | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1124 | 1218 | | |
0 commit comments