Skip to content
Snippets Groups Projects
Commit 3ed2b78b authored by Florian Pose's avatar Florian Pose
Browse files

Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.

--HG--
branch : stable-1.5
parent ad811c4f
No related branches found
No related tags found
No related merge requests found
/****************************************************************************** /******************************************************************************
* *
* $Id: master.c,v b5391b329b5d 2010/11/30 14:24:21 fp $ * $Id$
* *
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
* *
...@@ -821,6 +821,8 @@ void ec_master_queue_datagram( ...@@ -821,6 +821,8 @@ void ec_master_queue_datagram(
ec_datagram_t *datagram /**< datagram */ ec_datagram_t *datagram /**< datagram */
) )
{ {
ec_datagram_t *queued_datagram;
switch (datagram->state) { switch (datagram->state) {
case EC_DATAGRAM_QUEUED: case EC_DATAGRAM_QUEUED:
datagram->skip_count++; datagram->skip_count++;
...@@ -835,10 +837,27 @@ void ec_master_queue_datagram( ...@@ -835,10 +837,27 @@ void ec_master_queue_datagram(
break; break;
default: default:
list_add_tail(&datagram->queue, &master->datagram_queue);
datagram->state = EC_DATAGRAM_QUEUED;
break; break;
} }
/* It is possible, that a datagram in the queue is re-initialized with the
* ec_datagram_<type>() methods and then shall be queued with this method.
* In that case, the state is already reset to EC_DATAGRAM_INIT. Check if
* the datagram is queued to avoid duplicate queuing (which results in an
* infinite loop!). Set the state to EC_DATAGRAM_QUEUED again, probably
* causing an unmatched datagram. */
list_for_each_entry(queued_datagram, &master->datagram_queue, queue) {
if (queued_datagram == datagram) {
datagram->skip_count++;
EC_MASTER_DBG(master, 1, "Skipping re-initialized datagram %p.\n",
datagram);
datagram->state = EC_DATAGRAM_QUEUED;
return;
}
}
list_add_tail(&datagram->queue, &master->datagram_queue);
datagram->state = EC_DATAGRAM_QUEUED;
} }
/*****************************************************************************/ /*****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment