fixed race condition when comparing datagram state
authorMartin Troxler <ch1010277@ch10pc446>
Mon, 14 Mar 2011 16:08:25 +0100
changeset 2044 1ae0491b2f6b
parent 2041 f5b31f46c38f
child 2045 ff2a13a4603c
fixed race condition when comparing datagram state
EC_DATAGRAM_QUEUED must be compared before EC_DATAGRAM_SENT because it might change in between
master/ethernet.c
master/fsm_master.c
master/fsm_slave.c
master/fsm_slave_config.c
master/fsm_slave_scan.c
--- a/master/ethernet.c	Thu Feb 24 10:04:42 2011 +0100
+++ b/master/ethernet.c	Mon Mar 14 16:08:25 2011 +0100
@@ -324,7 +324,7 @@
 
     // if the datagram was not sent, or is not yet received, skip this cycle
     if (eoe->queue_datagram ||
-        eoe->datagram.state == EC_DATAGRAM_SENT || eoe->datagram.state == EC_DATAGRAM_QUEUED)
+        eoe->datagram.state == EC_DATAGRAM_QUEUED || eoe->datagram.state == EC_DATAGRAM_SENT)
         return;
 
     // call state function
--- a/master/fsm_master.c	Thu Feb 24 10:04:42 2011 +0100
+++ b/master/fsm_master.c	Mon Mar 14 16:08:25 2011 +0100
@@ -133,8 +133,8 @@
         ec_fsm_master_t *fsm /**< Master state machine. */
         )
 {
-    if (fsm->datagram->state == EC_DATAGRAM_SENT
-        || fsm->datagram->state == EC_DATAGRAM_QUEUED) {
+    if (fsm->datagram->state == EC_DATAGRAM_QUEUED
+        || fsm->datagram->state == EC_DATAGRAM_SENT) {
         // datagram was not sent or received yet.
         return 0;
     }
--- a/master/fsm_slave.c	Thu Feb 24 10:04:42 2011 +0100
+++ b/master/fsm_slave.c	Mon Mar 14 16:08:25 2011 +0100
@@ -101,8 +101,8 @@
         ec_fsm_slave_t *fsm /**< Slave state machine. */
         )
 {
-    if (fsm->datagram->state == EC_DATAGRAM_SENT
-        || fsm->datagram->state == EC_DATAGRAM_QUEUED) {
+    if (fsm->datagram->state == EC_DATAGRAM_QUEUED
+        || fsm->datagram->state == EC_DATAGRAM_SENT) {
         // datagram was not sent or received yet.
         return 0;
     }
--- a/master/fsm_slave_config.c	Thu Feb 24 10:04:42 2011 +0100
+++ b/master/fsm_slave_config.c	Mon Mar 14 16:08:25 2011 +0100
@@ -177,8 +177,8 @@
         ec_fsm_slave_config_t *fsm /**< slave state machine */
         )
 {
-    if (fsm->datagram->state == EC_DATAGRAM_SENT
-        || fsm->datagram->state == EC_DATAGRAM_QUEUED) {
+    if (fsm->datagram->state == EC_DATAGRAM_QUEUED
+        || fsm->datagram->state == EC_DATAGRAM_SENT) {
         // datagram was not sent or received yet.
         return ec_fsm_slave_config_running(fsm);
     }
--- a/master/fsm_slave_scan.c	Thu Feb 24 10:04:42 2011 +0100
+++ b/master/fsm_slave_scan.c	Mon Mar 14 16:08:25 2011 +0100
@@ -137,8 +137,8 @@
 
 int ec_fsm_slave_scan_exec(ec_fsm_slave_scan_t *fsm /**< slave state machine */)
 {
-    if (fsm->datagram->state == EC_DATAGRAM_SENT
-        || fsm->datagram->state == EC_DATAGRAM_QUEUED) {
+    if (fsm->datagram->state == EC_DATAGRAM_QUEUED
+        || fsm->datagram->state == EC_DATAGRAM_SENT) {
         // datagram was not sent or received yet.
         return ec_fsm_slave_scan_running(fsm);
     }