-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit 82ebd46
committed
Ensure non-empty buffers for large vectored I/O
`readv` and `writev` are constrained by a platform-specific upper bound
on the number of buffers which can be passed. Currently, `read_vectored`
and `write_vectored` implementations simply truncate to this limit when
larger. However, when the only non-empty buffers are at indices above
this limit, they will erroneously return `Ok(0)`.
Instead, slice the buffers starting at the first non-empty buffer. This
trades a conditional move for a branch, so it's barely a penalty in the
common case.
The new method `limit_slices` on `IoSlice` and `IoSliceMut` may be
generally useful to users like `advance_slices` is, but I have left it
as `pub(crate)` for now.1 parent 5cc6072 commit 82ebd46
6 files changed
+125
-53
lines changedLines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
297 | 297 |
| |
298 | 298 |
| |
299 | 299 |
| |
300 | + | ||
300 | 301 |
| |
301 | 302 |
| |
302 | 303 |
| |
| |||
1388 | 1389 |
| |
1389 | 1390 |
| |
1390 | 1391 |
| |
1392 | + | ||
1393 | + | ||
1394 | + | ||
1395 | + | ||
1396 | + | ||
1397 | + | ||
1398 | + | ||
1399 | + | ||
1400 | + | ||
1401 | + | ||
1402 | + | ||
1403 | + | ||
1404 | + | ||
1405 | + | ||
1406 | + | ||
1407 | + | ||
1408 | + | ||
1409 | + | ||
1391 | 1410 |
| |
1392 | 1411 |
| |
1393 | 1412 |
| |
| |||
1549 | 1568 |
| |
1550 | 1569 |
| |
1551 | 1570 |
| |
1571 | + | ||
1572 | + | ||
1573 | + | ||
1574 | + | ||
1575 | + | ||
1576 | + | ||
1577 | + | ||
1578 | + | ||
1579 | + | ||
1580 | + | ||
1581 | + | ||
1582 | + | ||
1583 | + | ||
1584 | + | ||
1585 | + | ||
1586 | + | ||
1587 | + | ||
1588 | + | ||
1552 | 1589 |
| |
1553 | 1590 |
| |
1554 | 1591 |
| |
|
Lines changed: 7 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
12 | - | ||
12 | + | ||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| |||
222 | 222 |
| |
223 | 223 |
| |
224 | 224 |
| |
225 | - | ||
225 | + | ||
226 | + | ||
226 | 227 |
| |
227 | - | ||
228 | - | ||
229 | - | ||
230 | - | ||
231 | - | ||
228 | + | ||
232 | 229 |
| |
233 | 230 |
| |
234 | 231 |
| |
| |||
267 | 264 |
| |
268 | 265 |
| |
269 | 266 |
| |
270 | - | ||
267 | + | ||
268 | + | ||
271 | 269 |
| |
272 | - | ||
273 | - | ||
274 | - | ||
275 | - | ||
276 | - | ||
270 | + | ||
277 | 271 |
| |
278 | 272 |
| |
279 | 273 |
| |
|
Lines changed: 15 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
299 | 299 |
| |
300 | 300 |
| |
301 | 301 |
| |
302 | - | ||
303 | - | ||
304 | 302 |
| |
305 | 303 |
| |
306 | 304 |
| |
| |||
309 | 307 |
| |
310 | 308 |
| |
311 | 309 |
| |
310 | + | ||
311 | + | ||
312 | + | ||
312 | 313 |
| |
313 | 314 |
| |
314 | 315 |
| |
| |||
332 | 333 |
| |
333 | 334 |
| |
334 | 335 |
| |
335 | - | ||
336 | - | ||
337 | - | ||
338 | - | ||
336 | + | ||
337 | + | ||
339 | 338 |
| |
340 | 339 |
| |
341 | 340 |
| |
342 | 341 |
| |
343 | 342 |
| |
344 | 343 |
| |
345 | - | ||
344 | + | ||
346 | 345 |
| |
347 | 346 |
| |
348 | 347 |
| |
| |||
355 | 354 |
| |
356 | 355 |
| |
357 | 356 |
| |
357 | + | ||
358 | + | ||
359 | + | ||
358 | 360 |
| |
359 | 361 |
| |
360 | 362 |
| |
| |||
384 | 386 |
| |
385 | 387 |
| |
386 | 388 |
| |
387 | - | ||
388 | - | ||
389 | 389 |
| |
390 | 390 |
| |
391 | 391 |
| |
| |||
401 | 401 |
| |
402 | 402 |
| |
403 | 403 |
| |
404 | + | ||
405 | + | ||
406 | + | ||
404 | 407 |
| |
405 | 408 |
| |
406 | 409 |
| |
| |||
419 | 422 |
| |
420 | 423 |
| |
421 | 424 |
| |
422 | - | ||
423 | - | ||
425 | + | ||
426 | + | ||
424 | 427 |
| |
425 | 428 |
| |
426 | 429 |
| |
427 | 430 |
| |
428 | 431 |
| |
429 | - | ||
432 | + | ||
430 | 433 |
| |
431 | 434 |
| |
432 | 435 |
| |
|
Lines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 | - | ||
5 | 4 |
| |
6 | 5 |
| |
7 | 6 |
| |
| |||
38 | 37 |
| |
39 | 38 |
| |
40 | 39 |
| |
41 | - | ||
40 | + | ||
41 | + | ||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 | 45 |
| |
46 | - | ||
46 | + | ||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
| |||
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
68 | - | ||
68 | + | ||
69 | + | ||
69 | 70 |
| |
70 | 71 |
| |
71 | 72 |
| |
72 | 73 |
| |
73 | - | ||
74 | + | ||
74 | 75 |
| |
75 | 76 |
| |
76 | 77 |
| |
|
0 commit comments