Commit 516f6db1 authored by Pfeiffer, Götz's avatar Pfeiffer, Götz
Browse files

Bugfix in sdo: the channel lock function had to be added again.


As tests show, this function *is* needed. This patch, however, tries to make
the implementation of channel locking a bit more systematic. A channel is
locked when it is put into the send or timeout queue. It is unlocked when it
is removed from that queue. Channel locking ensures that a channel cannot be
added to the send and the timeout queue at the same time.
parent 5c006e44
......@@ -308,13 +308,19 @@ static boolean channel_timeout_queue_iterate(int *iterator,
static boolean channel_timeout_queue_remove(sdo_channelP chan)
{
if (!sdo_channel_locked(chan))
return FALSE;
if (!pqueue_remove(&sdo_timeout_queue, chan))
return FALSE;
sdo_channel_unlock(chan);
return TRUE;
}
static void channel_timeout_queue_enqueue(sdo_channelP chan)
{
if (sdo_channel_locked(chan))
return;
sdo_channel_lock(chan);
sdo_channel_time_activate(chan);
pqueue_enqueue(&sdo_timeout_queue, chan);
}
......@@ -359,6 +365,7 @@ static sdo_channelP sendqueue_dequeue_channel(void)
sdo_channelP chan= (sdo_channelP )pqueue_dequeue_n(&sdo_send_queue);
if (chan==NULL)
return NULL;
sdo_channel_unlock(chan);
return chan;
}
......@@ -366,6 +373,9 @@ static sdo_channelP sendqueue_dequeue_channel(void)
static void sendqueue_enqueue_channel(sdo_channelP chan)
{ static char *me= "sendqueue_enqueue_channel";
if (sdo_channel_locked(chan))
return;
sdo_channel_lock(chan);
if (!pqueue_enqueue(&sdo_send_queue, chan))
return;
......@@ -1178,11 +1188,15 @@ prot_Return sdo_write (sdo_varP ptr) /*@EXI*/
DBG_ASRT_STRUC(SDO_CHANNEL_ASRT_TP,((sdo_Channel*)channel),"")
/* enqueue the channel only into the write-queue
if it is not locked */
/* enqueue the channel into the global send-queue if it's not
already in there, this notifies the GPS writer,
if the channel wasnt already in the queue */
sendqueue_enqueue_channel(channel);
SEM_GIVE;
DBG_TRC_PRINTF2(5,"%s: action: exit\n",me);
......
......@@ -138,6 +138,7 @@ typedef struct
the DBG_MAGIC macro would expand
differently when DBG_ASRT_COMP is
defined differently in the application */
boolean lock;
unsigned char port;
unsigned char node;
imapss basevar_map;
......@@ -299,6 +300,23 @@ static char *ptr2string(void *p)
/* export */
/*::::::::::::::::::::::::::::::::::::::::::::*/
boolean sdo_channel_lock(sdo_channelP channel) /* @EXI */
{ if (UNFOLD(channel)->lock)
return(FALSE);
UNFOLD(channel)->lock= TRUE;
return(TRUE);
}
boolean sdo_channel_unlock(sdo_channelP channel) /* @EXI */
{ if (!UNFOLD(channel)->lock)
return(FALSE);
UNFOLD(channel)->lock= FALSE;
return(TRUE);
}
boolean sdo_channel_locked(sdo_channelP channel) /* @EXI */
{ return(UNFOLD(channel)->lock); }
sdo_varP sdo_channel_var_processed(sdo_channelP channel) /* @EXI*/
{ return( UNFOLD(channel)->var_processed ); }
......@@ -351,6 +369,7 @@ sdo_channelP sdo_channel_new(unsigned char port,unsigned char node,
}
DBG_ASRT_INITSTRUC(SDO_CHANNEL_ASRT_TP,chan);
chan->lock= FALSE;
chan->port= port;
chan->node= node;
imapss_init(&(chan->basevar_map));
......@@ -565,6 +584,7 @@ void sdo_channel_dump_bpp(pbuf *p, sdo_channelP channel,
DBG_ASRT_STRUC(SDO_CHANNEL_ASRT_TP,chan,"")
sprintf(PA, "------------------------------\n");
sprintf(PA, "dump of sdo_Channel object at %p\n",chan);
sprintf(PA, "locked:%d\n",chan->lock);
sprintf(PA, "Port:%d Node:%d\n",chan->port,chan->node);
sprintf(PA, "basevar-map dump: \n");
if (basevartopbuf==NULL)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment