# HG changeset patch # User Florian Pose # Date 1310127985 -7200 # Node ID 775d1a02f2048d4acab4c0868258e4dbce34e482 # Parent 9c3fd68997d4f35337184a7c52c2bcfdd0bdd88f Improved ecrt_master_queue_datagram(); detect skipped datagrams also when already sent. diff -r 9c3fd68997d4 -r 775d1a02f204 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 @@ -1,6 +1,6 @@ /****************************************************************************** * - * $Id$ + * $Id: master.c,v b5391b329b5d 2010/11/30 14:24:21 fp $ * * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH * @@ -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++; }