Improved ecrt_master_queue_datagram(); detect skipped datagrams also when
authorFlorian Pose <fp@igh-essen.com>
Fri, 08 Jul 2011 14:26:25 +0200
changeset 2078 c9d32805d984
parent 2077 e8f690838311
child 2079 56993027a2d0
Improved ecrt_master_queue_datagram(); detect skipped datagrams also when
already sent.
master/master.c
--- a/master/master.c	Fri Jul 08 14:23:22 2011 +0200
+++ b/master/master.c	Fri Jul 08 14:26:25 2011 +0200
@@ -821,22 +821,24 @@
         ec_datagram_t *datagram /**< datagram */
         )
 {
-    ec_datagram_t *queued_datagram;
-
-    if (datagram->state == EC_DATAGRAM_SENT)
-        return;
-    // check, if the datagram is already queued
-    list_for_each_entry(queued_datagram, &master->datagram_queue, queue) {
-        if (queued_datagram == datagram) {
+    switch (datagram->state) {
+        case EC_DATAGRAM_QUEUED:
             datagram->skip_count++;
-            EC_MASTER_DBG(master, 1, "skipping datagram %p.\n", datagram);
+            EC_MASTER_DBG(master, 1, "Skipping already queued datagram %p.\n",
+                    datagram);
+            break;
+
+        case EC_DATAGRAM_SENT:
+            datagram->skip_count++;
+            EC_MASTER_DBG(master, 1, "Skipping already sent datagram %p.\n",
+                    datagram);
+            break;
+
+        default:
+            list_add_tail(&datagram->queue, &master->datagram_queue);
             datagram->state = EC_DATAGRAM_QUEUED;
-            return;
-        }
-    }
-
-    list_add_tail(&datagram->queue, &master->datagram_queue);
-    datagram->state = EC_DATAGRAM_QUEUED;
+            break;
+    }
 }
 
 /*****************************************************************************/
@@ -1303,7 +1305,8 @@
             }
             up(&master->master_sem);
 
-            // inject datagrams (let the rt thread queue them, see ecrt_master_send)
+            // inject datagrams (let the rt thread queue them, see
+            // ecrt_master_send)
             if (fsm_exec)
                 master->injection_seq_fsm++;
         }