Invalidate processing register requests when clearing configuration. stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Tue, 04 Dec 2012 12:23:43 +0100
branchstable-1.5
changeset 2459 8c7e674aa5d6
parent 2458 8e0bab31fddd
child 2460 611e4d745dcd
Invalidate processing register requests when clearing configuration.
master/fsm_slave.c
master/slave_config.c
--- a/master/fsm_slave.c	Tue Dec 04 12:22:38 2012 +0100
+++ b/master/fsm_slave.c	Tue Dec 04 12:23:43 2012 +0100
@@ -336,6 +336,12 @@
     ec_slave_t *slave = fsm->slave;
     ec_reg_request_t *reg = fsm->reg_request;
 
+    if (!reg) {
+        // configuration was cleared in the meantime
+        fsm->state = ec_fsm_slave_state_ready;
+        return;
+    }
+
     if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) {
         EC_SLAVE_ERR(slave, "Failed to receive register"
                 " request datagram: ");
--- a/master/slave_config.c	Tue Dec 04 12:22:38 2012 +0100
+++ b/master/slave_config.c	Tue Dec 04 12:23:43 2012 +0100
@@ -268,7 +268,18 @@
         )
 {
     if (sc->slave) {
+        ec_reg_request_t *reg;
+
         sc->slave->config = NULL;
+
+        // invalidate processing register request
+        list_for_each_entry(reg, &sc->reg_requests, list) {
+            if (sc->slave->fsm.reg_request == reg) {
+                sc->slave->fsm.reg_request = NULL;
+                break;
+            }
+        }
+
         sc->slave = NULL;
     }
 }