From 855c9bc8ab09a6ecc3cd843f68c48835df15e201 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 15 Sep 2023 13:11:02 +1000 Subject: [PATCH] Limit the consistency checks run in each loop Limit the number of consistency check run for a single user command to about 60. Maybe this could use times_up??? Signed-off-by: NeilBrown --- DOC/TODO.md | 6 +++++- core-mark.c | 3 +++ core-pane.c | 14 ++++++++++++++ core-pane.h | 2 ++ doc-text.c | 3 +++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/DOC/TODO.md b/DOC/TODO.md index 9e532bfa..59f408a3 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -29,6 +29,8 @@ the file. - [ ] selection-menu sub-menu for UPPER lower Caps ?? - [ ] selection-menu item for text-fill - [ ] selection-menu item for spell-check ?? +- [ ] notmuch - capture errors about multiple Subject lines and + display them better. ### Small @@ -82,6 +84,8 @@ Requirements for a v1.0 release Core features ------------- +- [ ] universal times_up tests might cause Close_mark or similar + not to be called. How can we avoid that? - [ ] If a pane wants to block mouse events from parents, as lib-view does, it shouldn't need to catch all the combinations, or it should be much easier @@ -128,7 +132,7 @@ Core features I need a simple way to intercept any change. - [X] switch-buffer in pop-up window - shouldn't kill the popup (does it?) - [X] explicitly guard against infinite loops in consistency checks -- [ ] skip consistency checks after several with no stop for input. +- [X] skip consistency checks after several with no stop for input. - [ ] unwanted docs too easily appear high in recent-list - *Output* - [ ] design a way for a keystroke to interrupt a long-running function. - [ ] extend Draw:measure protocol to allow constant-width-fonts to diff --git a/core-mark.c b/core-mark.c index a5f7dd96..b24d52b7 100644 --- a/core-mark.c +++ b/core-mark.c @@ -1205,6 +1205,9 @@ void doc_check_consistent(struct doc *d safe) int max = 1000; static bool warned = False; + if (pane_no_consistency(safe_cast container_of(d, struct pane, doc))) + return; + hlist_for_each_entry(m, &d->marks, all) { ASSERT(m->seq >= seq); ASSERT(&m->owner->doc == d); diff --git a/core-pane.c b/core-pane.c index b772bc9e..5a872df8 100644 --- a/core-pane.c +++ b/core-pane.c @@ -1239,3 +1239,17 @@ void pane_set_time(struct pane *p safe) if (p->timestamp <= 1) p->timestamp = 2; } + +DEF_CB(clear_consistency) +{ + ci->focus->consistency_checks = 0; + return 1; +} + +bool pane_no_consistency(struct pane *p safe) +{ + p->consistency_checks += 1; + if (p->consistency_checks == 50) + call_comm("event:on-idle", p, &clear_consistency, 2); + return p->consistency_checks > 60; +} diff --git a/core-pane.h b/core-pane.h index 2d819e10..907cc1b1 100644 --- a/core-pane.h +++ b/core-pane.h @@ -11,6 +11,7 @@ struct pane { short damaged; short alloc_size; + short consistency_checks; int marks; int refs; @@ -52,6 +53,7 @@ struct pane { }; }; +bool pane_no_consistency(struct pane *p safe); bool pane_too_long(struct pane *p safe, unsigned int msec); void pane_set_time(struct pane *p safe); static inline void pane_end_time(struct pane *p safe) diff --git a/doc-text.c b/doc-text.c index b8d44616..e99edddd 100644 --- a/doc-text.c +++ b/doc-text.c @@ -2086,6 +2086,9 @@ static void text_check_consistent(struct text *t safe) struct doc *d = &t->doc; int loops = 10000; + if (pane_no_consistency(safe_cast container_of(d, struct pane, doc))) + return; + list_for_each_entry(c, &t->text, lst) { check_allocated(t, c->txt, c->end); if (c->start >= c->end) -- 2.39.5