Clear configuration on deactivation; also in userspace.
authorFlorian Pose <fp@igh-essen.com>
Thu, 16 Sep 2010 08:41:19 +0200
changeset 1960 6c4269dca1c2
parent 1959 656f114153c2
child 1961 48f536aefc18
Clear configuration on deactivation; also in userspace.
lib/master.c
--- a/lib/master.c	Thu Sep 16 08:35:21 2010 +0200
+++ b/lib/master.c	Thu Sep 16 08:41:19 2010 +0200
@@ -53,21 +53,18 @@
 
 /*****************************************************************************/
 
-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 @@
         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 @@
         fprintf(stderr, "Failed to deactivate master: %s\n", strerror(errno));
         return;
     }
-}
-
+
+    ec_master_clear_config(master);
+}
 
 /*****************************************************************************/
 
@@ -472,7 +482,6 @@
     return 0;
 }
 
-
 /*****************************************************************************/
 
 void ecrt_master_send(ec_master_t *master)