diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-20 14:18:05 +0000 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-20 14:18:05 +0000 |
commit | c204b3f4299cc3c3f61ebbc5c2223fa913ce5424 (patch) | |
tree | 0881913bb63e9b798af12b338d54bccf543edcd0 /lib/qtimers.c | |
parent | 13fad04d09978db15317d3d3fb71ab87ea52c110 (diff) | |
download | quagga-c204b3f4299cc3c3f61ebbc5c2223fa913ce5424.tar.bz2 quagga-c204b3f4299cc3c3f61ebbc5c2223fa913ce5424.tar.xz |
Adding verify debug code for qtimers and tidied up.
modified: bgpd/bgp_connection.c -- using _unset functions
-- added bgp_connection_close_file
modified: bgpd/bgp_connection.h
modified: bgpd/bgp_fsm.c -- checked notification handling
-- uses bgp_connection_close_file
modified: bgpd/bgp_notification.c -- added _unset function
modified: bgpd/bgp_notification.h
modified: bgpd/bgp_open_state.c -- added _unset function
modified: bgpd/bgp_open_state.h
modified: lib/qtimers.c -- added debug _verify function
modified: lib/qtimers.h
modified: lib/sockunion.c -- added _unset function
modified: lib/sockunion.h
Diffstat (limited to 'lib/qtimers.c')
-rw-r--r-- | lib/qtimers.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/qtimers.c b/lib/qtimers.c index 43335d55..a5d0e27b 100644 --- a/lib/qtimers.c +++ b/lib/qtimers.c @@ -154,6 +154,8 @@ qtimer_pile_dispatch_next(qtimer_pile qtp, qtime_mono_t upto) { qtimer qtr ; + qtimer_pile_verify(qtp) ; /* TODO: remove after debuggery */ + qtr = heap_top_item(&qtp->timers) ; if ((qtr != NULL) && (qtr->time <= upto)) { @@ -321,6 +323,7 @@ qtimer_set(qtimer qtr, qtime_mono_t when, qtimer_action* action) qtp = qtr->pile ; dassert(qtp != NULL) ; assert(qtp == our_pile); + qtimer_pile_verify(qtp) ; /* TODO: remove after debuggery */ qtr->time = when ; @@ -328,7 +331,9 @@ qtimer_set(qtimer qtr, qtime_mono_t when, qtimer_action* action) heap_update_item(&qtp->timers, qtr) ; /* update in heap */ else heap_push_item(&qtp->timers, qtr) ; /* add to heap */ + assert(qtp == qtr->pile); + qtimer_pile_verify(qtp) ; /* TODO: remove after debuggery */ qtr->state = qtr_state_active ; /* overrides any unset pending */ @@ -349,11 +354,46 @@ qtimer_unset(qtimer qtr) { qtimer_pile qtp = qtr->pile ; dassert(qtp != NULL) ; + assert(qtp == our_pile); + qtimer_pile_verify(qtp) ; /* TODO: remove after debuggery */ heap_delete_item(&qtp->timers, qtr) ; + assert(qtp == qtr->pile); + qtimer_pile_verify(qtp) ; /* TODO: remove after debuggery */ qtr->state = qtr_state_inactive ; /* overrides any unset pending */ } ; } ; + +/*============================================================================== + * Verification code for debug purposes. + */ +extern void +qtimer_pile_verify(qtimer_pile qtp) +{ + heap th = &qtp->timers ; + vector v ; + vector_index i ; + vector_index e ; + qtimer qtr ; + + /* Eclipse flags offsetof(struct qtimer, backlink) as a syntax error :-( */ + typedef struct qtimer qtimer_t ; + + assert(th->cmp == (heap_cmp*)qtimer_cmp) ; + assert(th->state == Heap_Has_Backlink) ; + assert(th->backlink_offset == offsetof(qtimer_t, backlink)) ; + + v = &th->v ; + e = vector_end(v) ; + for (i = 0 ; i < e ; ++i) + { + qtr = vector_get_item(v, i) ; + + assert(qtr->pile == qtp) ; + assert(qtr->backlink == i) ; + assert(qtr->action != NULL) ; + } ; +} ; |