Commit 89f378a
authored
Keep APM and sync UploadFile/DownloadFile callbacks on the threadpool (sshnet#1805)
* Tweak internal IProgress usage for APM and sync UploadFile/DownloadFile
Changes to support IProgress<> callback on UploadAsync/DownloadAsync meant wrapping
the Action<> callback on existing methods in a Progress<>, which posts the callback
onto the current synchronisation context rather than the threadpool. For the legacy
APM methods (Begin[..]), let's just preserve their old behaviour.
For the synchronous methods, posting to the synchronisation context is probably the
worst choice (because if there is one, the method itself is running there). We can
either revert to the threadpool as well, or take the opportunity to invoke the
callback synchronously, which is a behavioural change but probably the least
surprising behaviour for a synchronous method.
* keep callbacks on the threadpool
Actually, we could call the Download callback synchronously easily enough, but the Upload progress
reports are being made on the message listener thread upon request ack. A more involved
scheme could drain callbacks to fire during the read loop. For now just make it all the
same behaviour as in 2025.1.0.1 parent fa98d59 commit 89f378a
2 files changed
Lines changed: 123 additions & 63 deletions
File tree
- src/Renci.SshNet
- test/Renci.SshNet.IntegrationTests/OldIntegrationTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
906 | 906 | | |
907 | 907 | | |
908 | 908 | | |
909 | | - | |
| 909 | + | |
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
| |||
935 | 935 | | |
936 | 936 | | |
937 | 937 | | |
938 | | - | |
| 938 | + | |
939 | 939 | | |
940 | 940 | | |
941 | 941 | | |
| |||
1012 | 1012 | | |
1013 | 1013 | | |
1014 | 1014 | | |
1015 | | - | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
1016 | 1020 | | |
1017 | 1021 | | |
1018 | 1022 | | |
| |||
1090 | 1094 | | |
1091 | 1095 | | |
1092 | 1096 | | |
1093 | | - | |
| 1097 | + | |
1094 | 1098 | | |
1095 | 1099 | | |
1096 | 1100 | | |
| |||
1274 | 1278 | | |
1275 | 1279 | | |
1276 | 1280 | | |
1277 | | - | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1278 | 1286 | | |
1279 | 1287 | | |
1280 | 1288 | | |
| |||
2418 | 2426 | | |
2419 | 2427 | | |
2420 | 2428 | | |
2421 | | - | |
| 2429 | + | |
2422 | 2430 | | |
2423 | | - | |
2424 | | - | |
2425 | | - | |
2426 | | - | |
2427 | | - | |
2428 | | - | |
2429 | | - | |
2430 | | - | |
| 2431 | + | |
| 2432 | + | |
2431 | 2433 | | |
2432 | 2434 | | |
2433 | 2435 | | |
| |||
2546 | 2548 | | |
2547 | 2549 | | |
2548 | 2550 | | |
2549 | | - | |
2550 | | - | |
| 2551 | + | |
2551 | 2552 | | |
2552 | | - | |
2553 | | - | |
2554 | | - | |
2555 | | - | |
2556 | | - | |
2557 | | - | |
2558 | | - | |
| 2553 | + | |
| 2554 | + | |
2559 | 2555 | | |
2560 | 2556 | | |
2561 | 2557 | | |
| |||
2662 | 2658 | | |
2663 | 2659 | | |
2664 | 2660 | | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
2665 | 2685 | | |
2666 | 2686 | | |
Lines changed: 80 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | | - | |
328 | | - | |
329 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
330 | 333 | | |
331 | 334 | | |
332 | 335 | | |
333 | 336 | | |
334 | 337 | | |
335 | 338 | | |
336 | | - | |
| 339 | + | |
| 340 | + | |
337 | 341 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
348 | 346 | | |
349 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
350 | 357 | | |
351 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
352 | 363 | | |
353 | 364 | | |
354 | 365 | | |
355 | | - | |
| 366 | + | |
| 367 | + | |
356 | 368 | | |
357 | 369 | | |
358 | 370 | | |
359 | 371 | | |
360 | | - | |
| 372 | + | |
361 | 373 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 374 | + | |
| 375 | + | |
370 | 376 | | |
371 | | - | |
| 377 | + | |
372 | 378 | | |
373 | | - | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
374 | 389 | | |
375 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
376 | 395 | | |
377 | 396 | | |
378 | 397 | | |
379 | | - | |
| 398 | + | |
| 399 | + | |
380 | 400 | | |
381 | 401 | | |
382 | 402 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 403 | + | |
393 | 404 | | |
394 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
395 | 421 | | |
396 | 422 | | |
397 | | - | |
| 423 | + | |
| 424 | + | |
398 | 425 | | |
399 | 426 | | |
400 | 427 | | |
| |||
482 | 509 | | |
483 | 510 | | |
484 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
485 | 525 | | |
486 | 526 | | |
0 commit comments