Changeset 9c615b7 in rtems


Ignore:
Timestamp:
01/04/16 08:55:59 (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11
Children:
cb7c6f5
Parents:
b4350d1
git-author:
Sebastian Huber <sebastian.huber@…> (01/04/16 08:55:59)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/05/16 06:09:56)
Message:

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.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/watchdoginsert.c

    rb4350d1 r9c615b7  
    2323static void _Watchdog_Insert_fixup(
    2424  Watchdog_Header   *header,
     25  Watchdog_Control  *the_watchdog,
     26  Watchdog_Interval  delta,
    2527  Watchdog_Control  *next_watchdog,
    26   Watchdog_Interval  delta
     28  Watchdog_Interval  delta_next
    2729)
    2830{
     
    3032  Chain_Node       *iterator_node;
    3133
    32   next_watchdog->delta_interval -= delta;
     34  next_watchdog->delta_interval = delta_next - delta;
    3335
    3436  iterator_node = _Chain_First( &header->Iterators );
     
    4143
    4244    if ( iterator->current == &next_watchdog->Node ) {
    43       iterator->delta_interval -= delta;
     45      iterator->current = &the_watchdog->Node;
    4446    }
    4547
     
    7779
    7880      if ( delta < delta_next ) {
    79         _Watchdog_Insert_fixup( header, next_watchdog, delta );
     81        _Watchdog_Insert_fixup(
     82          header,
     83          the_watchdog,
     84          delta,
     85          next_watchdog,
     86          delta_next
     87        );
    8088        break;
    8189      }
  • testsuites/sptests/spwatchdog/init.c

    rb4350d1 r9c615b7  
    132132  d->initial = 3;
    133133  _Watchdog_Insert( &header, d );
    134   rtems_test_assert( i.delta_interval == 1 );
    135   rtems_test_assert( i.current == &b->Node );
     134  rtems_test_assert( i.delta_interval == 2 );
     135  rtems_test_assert( i.current == &d->Node );
    136136
    137137  destroy_watchdogs( &header );
     
    193193  rtems_test_assert( a->delta_interval == 2 );
    194194  rtems_test_assert( c->delta_interval == 4 );
    195   rtems_test_assert( i.delta_interval == 4 );
    196   rtems_test_assert( i.current == &a->Node );
     195  rtems_test_assert( i.delta_interval == 8 );
     196  rtems_test_assert( i.current == &c->Node );
     197
     198  destroy_watchdogs( &header );
     199}
     200
     201static void init_watchdogs_insert_with_iterator(
     202  Watchdog_Header *header,
     203  Watchdog_Control watchdogs[2]
     204)
     205{
     206  Watchdog_Control *a = &watchdogs[0];
     207  Watchdog_Control *b = &watchdogs[1];
     208
     209  _Watchdog_Preinitialize( a );
     210  _Watchdog_Preinitialize( b );
     211
     212  _Watchdog_Header_initialize( header );
     213
     214  a->initial = 6;
     215  _Watchdog_Insert( header, a );
     216  rtems_test_assert( a->delta_interval == 6 );
     217}
     218
     219static void test_watchdog_insert_with_iterator( void )
     220{
     221  Watchdog_Header header;
     222  Watchdog_Control watchdogs[2];
     223  Watchdog_Control *a = &watchdogs[0];
     224  Watchdog_Control *b = &watchdogs[1];
     225  Watchdog_Iterator i;
     226
     227  init_watchdogs_insert_with_iterator( &header, watchdogs );
     228  add_iterator( &header, &i, a );
     229
     230  b->initial = 4;
     231  _Watchdog_Insert( &header, b );
     232  rtems_test_assert( a->delta_interval == 2 );
     233  rtems_test_assert( b->delta_interval == 4 );
     234  rtems_test_assert( i.delta_interval == 2 );
     235  rtems_test_assert( i.current == &b->Node );
    197236
    198237  destroy_watchdogs( &header );
     
    237276  test_watchdog_insert_and_remove();
    238277  test_watchdog_remove_second_and_insert_first();
     278  test_watchdog_insert_with_iterator();
    239279
    240280  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
Note: See TracChangeset for help on using the changeset viewer.