From 24531d48ba50eabe51454eeb6678ad5380eaaf22 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 11 May 2008 22:04:32 +0000 Subject: [PATCH] do not crash if we go out of Run with reserved movements - tell safety we're quitting --- hostside/safety.c | 10 ++++++++++ hostside/safety.h | 1 + hostside/startup.c | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hostside/safety.c b/hostside/safety.c index 851ed8a..2320dc1 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -977,3 +977,13 @@ ErrorCode safety_check_movposchange(Segment *seg, } return 0; } + +void safety_abandon_run(void) { + SEG_IV; + + FOR_SEG { + if (seg->moving) continue; + movpos_unreserve(seg->motion); + seg->motion= 0; + } +} diff --git a/hostside/safety.h b/hostside/safety.h index 7ce4ffa..d256c4d 100644 --- a/hostside/safety.h +++ b/hostside/safety.h @@ -123,6 +123,7 @@ void report_train_ownerships(Train *tra, Segment *furthest, /* ... for use by things which update these only, which * is basically safety.c and resolve.c */ +void safety_abandon_run(void); /*========== movpos.c ==========*/ /* diff --git a/hostside/startup.c b/hostside/startup.c index d933df1..7e33d0c 100644 --- a/hostside/startup.c +++ b/hostside/startup.c @@ -87,8 +87,10 @@ static void sta_goto(StartupState new_state) { if (new_state < Sta_Run) choreographers_all_abandon(); - if (new_state < Sta_Finalising) + if (new_state < Sta_Finalising) { + safety_abandon_run(); motions_all_abandon(); + } piob.l= 0; switch (new_state) { -- 2.30.2