Commit 21ba5bb
authored
[coap] ensure correct retransmission timer scheduling (openthread#11348)
This commit introduces `CoapBase::ScheduleRetransmissionTimer()`, a
new method that calculates the next retransmission timer fire time
based on all queued messages in `mPendingRequests` and then
schedules (starts or stops) the timer.
This method is now used whenever `mPendingRequests` is updated (a new
message is added or an existing message is removed). It is also used
in `HandleRetransmissionTimer()`, the timer's callback. This change
centralizes timer scheduling, simplifying the logic.
This also addresses an issue in the existing code where
`HandleRetransmissionTimer()` iterated over `mPendingRequests` to
determine expired messages and calculate the next fire time. However,
finalizing an expired message could trigger its `ResponseHandler`
callback, from which the caller may start or abort CoAP message tx
and modify `mPendingRequests` and reschedule the timer, leading to
incorrect fire time calculations (`NextFireTime` can be incorrect
which would then improperly re-schedules the timer, stop it or
schedule it to a later time).
With this change, `HandleRetransmissionTimer()` first finalizes
expired messages (potentially invoking callbacks) and then calls
`ScheduleRetransmissionTimer()` to calculate the next fire time
based on the updated `mPendingRequests`, ensuring accurate timer
scheduling.1 parent d095eb3 commit 21ba5bb
2 files changed
+33
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
451 | 476 | | |
452 | 477 | | |
453 | 478 | | |
454 | 479 | | |
455 | 480 | | |
456 | 481 | | |
457 | 482 | | |
458 | | - | |
| 483 | + | |
459 | 484 | | |
460 | 485 | | |
461 | 486 | | |
462 | 487 | | |
463 | 488 | | |
464 | 489 | | |
465 | 490 | | |
466 | | - | |
| 491 | + | |
467 | 492 | | |
468 | 493 | | |
469 | 494 | | |
| |||
483 | 508 | | |
484 | 509 | | |
485 | 510 | | |
486 | | - | |
| 511 | + | |
487 | 512 | | |
488 | 513 | | |
489 | 514 | | |
| |||
501 | 526 | | |
502 | 527 | | |
503 | 528 | | |
504 | | - | |
505 | | - | |
506 | 529 | | |
507 | 530 | | |
508 | | - | |
| 531 | + | |
509 | 532 | | |
510 | 533 | | |
511 | 534 | | |
| |||
550 | 573 | | |
551 | 574 | | |
552 | 575 | | |
553 | | - | |
554 | | - | |
555 | 576 | | |
| 577 | + | |
556 | 578 | | |
557 | 579 | | |
558 | 580 | | |
| |||
561 | 583 | | |
562 | 584 | | |
563 | 585 | | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
| 586 | + | |
| 587 | + | |
575 | 588 | | |
576 | 589 | | |
577 | 590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
| 824 | + | |
824 | 825 | | |
825 | 826 | | |
826 | 827 | | |
| |||
0 commit comments