Bugfix: Unqueue datagram before destroying.
authorFlorian Pose <fp@igh-essen.com>
Thu, 29 Oct 2009 17:28:49 +0100
changeset 1553 4e8d56d6f12a
parent 1552 c9e2c3be294e
child 1554 e07a0f8de03d
Bugfix: Unqueue datagram before destroying.
master/datagram.c
master/datagram.h
master/domain.c
--- a/master/datagram.c	Wed Oct 28 14:59:34 2009 +0100
+++ b/master/datagram.c	Thu Oct 29 17:28:49 2009 +0100
@@ -116,6 +116,8 @@
  */
 void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram. */)
 {
+    ec_datagram_unqueue(datagram);
+
     if (datagram->data_origin == EC_ORIG_INTERNAL && datagram->data) {
         kfree(datagram->data);
         datagram->data = NULL;
@@ -124,6 +126,17 @@
 
 /*****************************************************************************/
 
+/** Unqueue datagram.
+ */
+void ec_datagram_unqueue(ec_datagram_t *datagram /**< EtherCAT datagram. */)
+{
+    if (!list_empty(&datagram->queue)) {
+        list_del_init(&datagram->queue);
+    }
+}
+
+/*****************************************************************************/
+
 /** Allocates internal payload memory.
  *
  * If the allocated memory is already larger than requested, nothing ist done.
--- a/master/datagram.h	Wed Oct 28 14:59:34 2009 +0100
+++ b/master/datagram.h	Thu Oct 29 17:28:49 2009 +0100
@@ -115,6 +115,7 @@
 
 void ec_datagram_init(ec_datagram_t *);
 void ec_datagram_clear(ec_datagram_t *);
+void ec_datagram_unqueue(ec_datagram_t *);
 int ec_datagram_prealloc(ec_datagram_t *, size_t);
 void ec_datagram_zero(ec_datagram_t *);
 
--- a/master/domain.c	Wed Oct 28 14:59:34 2009 +0100
+++ b/master/domain.c	Thu Oct 29 17:28:49 2009 +0100
@@ -80,8 +80,6 @@
 
     // dequeue and free datagrams
     list_for_each_entry_safe(datagram, next, &domain->datagrams, list) {
-        if (!list_empty(&datagram->queue)) // datagram queued?
-            list_del(&datagram->queue);
         ec_datagram_clear(datagram);
         kfree(datagram);
     }