From 9c615b7835f397698e0b8c41fa598180cee8ce7a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 4 Jan 2016 09:55:59 +0100 Subject: score: Fix watchdog insert Under certain conditions a new watchdog was inserted with a wrong and very large delta interval due to a wrong iterator update. Bug was introduced by 1ccbd052910ed16131c74b0d5595c8a94066942d. Close #2507. --- cpukit/score/src/watchdoginsert.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'cpukit') diff --git a/cpukit/score/src/watchdoginsert.c b/cpukit/score/src/watchdoginsert.c index 6b81c7b872..db15f55b0d 100644 --- a/cpukit/score/src/watchdoginsert.c +++ b/cpukit/score/src/watchdoginsert.c @@ -22,14 +22,16 @@ static void _Watchdog_Insert_fixup( Watchdog_Header *header, + Watchdog_Control *the_watchdog, + Watchdog_Interval delta, Watchdog_Control *next_watchdog, - Watchdog_Interval delta + Watchdog_Interval delta_next ) { const Chain_Node *iterator_tail; Chain_Node *iterator_node; - next_watchdog->delta_interval -= delta; + next_watchdog->delta_interval = delta_next - delta; iterator_node = _Chain_First( &header->Iterators ); iterator_tail = _Chain_Immutable_tail( &header->Iterators ); @@ -40,7 +42,7 @@ static void _Watchdog_Insert_fixup( iterator = (Watchdog_Iterator *) iterator_node; if ( iterator->current == &next_watchdog->Node ) { - iterator->delta_interval -= delta; + iterator->current = &the_watchdog->Node; } iterator_node = _Chain_Next( iterator_node ); @@ -76,7 +78,13 @@ void _Watchdog_Insert_locked( delta_next = next_watchdog->delta_interval; if ( delta < delta_next ) { - _Watchdog_Insert_fixup( header, next_watchdog, delta ); + _Watchdog_Insert_fixup( + header, + the_watchdog, + delta, + next_watchdog, + delta_next + ); break; } -- cgit v1.2.3