Mercurial > emacs
changeset 27903:cc3d4c12e03b
(cancel_atimer): Handle canceling an atimer when
some timers are stopped.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 29 Feb 2000 09:31:42 +0000 |
parents | 27af8b008c69 |
children | af501f05394a |
files | src/atimer.c |
diffstat | 1 files changed, 28 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/atimer.c Tue Feb 29 09:31:20 2000 +0000 +++ b/src/atimer.c Tue Feb 29 09:31:42 2000 +0000 @@ -169,29 +169,38 @@ struct atimer *timer; { struct atimer *t, *prev; - - /* May not be called when some timers are stopped. */ - if (stopped_atimers) - abort (); + struct atimer **list; BLOCK_ATIMERS; - /* See if TIMER is active. */ - for (t = atimers, prev = 0; t && t != timer; t = t->next) - ; + /* If we've stopped all other timers except TIMER, we can + just reset the list of active atimers to null. */ + if (stopped_atimers && timer == atimers) + { + timer->next = free_atimers; + free_atimers = timer; + atimers = NULL; + } + else + { + /* See if TIMER is active or stopped. */ + list = stopped_atimers ? &stopped_atimers : &atimers; + for (t = *list, prev = 0; t && t != timer; t = t->next) + ; - /* If it is, take it off the list of active timers, put in on the - free-list. We don't bother to arrange for setting a different - alarm time, since a too early one doesn't hurt. */ - if (t) - { - if (prev) - prev->next = t->next; - else - atimers = t->next; - - t->next = free_atimers; - free_atimers = t; + /* If it is, take it off the list of its list, and put in on the + free-list. We don't bother to arrange for setting a + different alarm time, since a too early one doesn't hurt. */ + if (t) + { + if (prev) + prev->next = t->next; + else + *list = t->next; + + t->next = free_atimers; + free_atimers = t; + } } UNBLOCK_ATIMERS;