From feb8ccdd650d4b9af63ba377969e04aacf135168 Mon Sep 17 00:00:00 2001 From: Florian Pose <fp@igh-essen.com> Date: Thu, 16 Sep 2010 08:41:19 +0200 Subject: [PATCH] Clear configuration on deactivation; also in userspace. --- lib/master.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/master.c b/lib/master.c index 193d7e57..9b208bb9 100644 --- a/lib/master.c +++ b/lib/master.c @@ -53,21 +53,18 @@ int ecrt_master_reserve(ec_master_t *master) /*****************************************************************************/ -void ec_master_clear(ec_master_t *master) +void ec_master_clear_config(ec_master_t *master) { ec_domain_t *d, *next_d; ec_slave_config_t *c, *next_c; - if (master->process_data) { - munmap(master->process_data, master->process_data_size); - } - d = master->first_domain; while (d) { next_d = d->next; ec_domain_clear(d); d = next_d; } + master->first_domain = NULL; c = master->first_config; while (c) { @@ -75,6 +72,18 @@ void ec_master_clear(ec_master_t *master) ec_slave_config_clear(c); c = next_c; } + master->first_config = NULL; +} + +/*****************************************************************************/ + +void ec_master_clear(ec_master_t *master) +{ + if (master->process_data) { + munmap(master->process_data, master->process_data_size); + } + + ec_master_clear_config(master); if (master->fd != -1) { close(master->fd); @@ -456,8 +465,9 @@ void ecrt_master_deactivate(ec_master_t *master) fprintf(stderr, "Failed to deactivate master: %s\n", strerror(errno)); return; } -} + ec_master_clear_config(master); +} /*****************************************************************************/ @@ -472,7 +482,6 @@ int ecrt_master_set_send_interval(ec_master_t *master,size_t send_interval_us) return 0; } - /*****************************************************************************/ void ecrt_master_send(ec_master_t *master) -- GitLab