Commit 3813411
committed
luci-base: mark background poll XHRs with X-Ubus-No-Touch header
LuCI polls rpcd every few seconds to refresh the page and check
session status. These background XHRs inadvertently reset the rpcd
session idle timer, so 'option sessiontime' in /etc/config/rpcd has
no effect in practice — the session never expires while a LuCI tab
is open, even if the user is not actively using it.
Fix this by setting an X-Ubus-No-Touch: 1 request header on XHRs that
are not driven by a user gesture, so the server side can opt out of
refreshing the idle timer for them.
Capture-phase document listeners for common user interaction event types
record a timestamp (Request.lastUserInteraction) on every gesture.
Request.request() computes opt.background synchronously — before the
Promise.resolve() deferral — by comparing that timestamp against a
BACKGROUND_THRESHOLD (5 s). This survives async continuations: RPCs
issued from .then() chains after an intervening network round-trip or
modal confirmation (e.g. ui.changes.apply, uci.save) are treated as
foreground for as long as the user's last gesture is recent.
For the batched ubus path flushRequestQueue() sets X-Ubus-No-Touch only
when every entry in the batch carries opt.background, so a foreground
RPC sharing a batch with a background poll still touches the session.
Companion patches:
rpcd: honour notouch in session/access
uhttpd: parse X-Ubus-No-Touch and forward notouch to rpcd
Signed-off-by: Michael Pfeifroth <micpf@westermo.com>1 parent 1c70b2b commit 3813411
1 file changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
517 | 525 | | |
518 | 526 | | |
519 | 527 | | |
| |||
570 | 578 | | |
571 | 579 | | |
572 | 580 | | |
| 581 | + | |
| 582 | + | |
573 | 583 | | |
574 | 584 | | |
575 | 585 | | |
| |||
605 | 615 | | |
606 | 616 | | |
607 | 617 | | |
| 618 | + | |
| 619 | + | |
608 | 620 | | |
609 | 621 | | |
610 | 622 | | |
| |||
665 | 677 | | |
666 | 678 | | |
667 | 679 | | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
668 | 685 | | |
669 | 686 | | |
670 | 687 | | |
| |||
689 | 706 | | |
690 | 707 | | |
691 | 708 | | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
692 | 713 | | |
693 | 714 | | |
694 | 715 | | |
| |||
698 | 719 | | |
699 | 720 | | |
700 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
701 | 725 | | |
702 | 726 | | |
703 | 727 | | |
| |||
787 | 811 | | |
788 | 812 | | |
789 | 813 | | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
790 | 817 | | |
791 | 818 | | |
792 | 819 | | |
| |||
0 commit comments