Skip to content
Snippets Groups Projects
Commit ee59d7e9 authored by Jonathan Hanks's avatar Jonathan Hanks
Browse files

Fix counting of disconnected/connected channels in the standalone_edc

You can get into a situation where multiple disconnect events happen
w/o connection events.  This makes it look like the code cannot count
connected channels.  Only change the counts when we have a change from
the current state.
parent e9cb5b2b
No related branches found
No related tags found
No related merge requests found
......@@ -576,11 +576,23 @@ connectCallback( struct connection_handler_args args )
{
// **************************************************************************
int* channel_status = (int*)ca_puser( args.chid );
*channel_status = args.op == CA_OP_CONN_UP ? 0 : 0xbad;
if ( args.op == CA_OP_CONN_UP )
daqd_edcu1.con_chans++;
else
daqd_edcu1.con_chans--;
int new_status = ( args.op == CA_OP_CONN_UP ? 0 : 0xbad );
/* In practice we have seen multiple disconnect events in a row w/o a
* connect event. So only update when there is a change. Otherwise this
* code cannot count well.
*/
if ( *channel_status != new_status )
{
*channel_status = new_status;
if ( args.op == CA_OP_CONN_UP )
{
daqd_edcu1.con_chans++;
}
else
{
daqd_edcu1.con_chans--;
}
}
daqd_edcu1.con_events++;
}
......
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