Bugfix: Unqueue datagram before destroying.

This commit is contained in:
Florian Pose 2009-10-29 17:28:49 +01:00
parent fa26232937
commit 49c2f676d5
3 changed files with 14 additions and 2 deletions

View File

@ -116,6 +116,8 @@ void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram. */)
*/
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 @@ void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram. */)
/*****************************************************************************/
/** 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.

View File

@ -115,6 +115,7 @@ typedef struct {
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 *);

View File

@ -80,8 +80,6 @@ void ec_domain_clear(ec_domain_t *domain /**< EtherCAT domain */)
// 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);
}