1
0
mirror of https://github.com/stargieg/bacnet-stack synced 2025-10-26 23:35:52 +08:00
bacnet-stack/ports/linux
Steve Karg 0f0fb2664d [r3138] Merged revision(s) 3136 from branches/releases/bacnet-stack-0-8-0:
Replace Receive_Packet_Flag conditional variable with a semaphore and update the related library functions accordingly.
Analysis of the problem determined that the issue lay in the transfer of APDU packets between the FSM and the APDU packet handler thread.
The mechanism previously used by the FSM to notify the APDU packet handler thread that a packet was available for processing used a pthread conditional variable which packet handler thread was supposed to wait on before being signalled by the FSM.
However the packet handler thread has other tasks to perform and sometimes was not waiting on the conditional variable which it was signalled.
Unlike other synchronisation mechanisms such as semaphores, if the waiting task (the consumer) is not blocked on the conditional variable when the producer signals, then that signal is lost and the consumer is never signalled again, leading to a continual sequence of timeouts on the conditional variable.
This in turn led to the packet handler thread never being notified of a packet waiting to be processed thus causing the interface hang.
The main problem is that a conditional variable is supposed to be used with a mutex to prevent this behaviour occurring, but this mutex was not present (and in fact had been removed from the code, most likely because it was causing other synchronisation issues)
Further inspection revealed that this code was copied from another file but modified to remove the mutex which is an essential part of using a conditional variable for synchronisation. This then prevents the producer task being blocked until the consumer task is waiting on the conditional variable, thus leading to a race condition which is causing the issues seen.
The fix is to replace the conditional variable with a semaphore as this provides the required mechanism in this case.
Thank you Ian Smith at Abelon Systems Ltd. for the patch!

........
2018-03-25 16:09:35 +02:00
..
arcnet.c fork from http://sourceforge.net/projects/bacnet/ 2013-03-21 22:53:31 +01:00
bacnet_ipv6.lua update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
bacsec_linux.c update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
bip-init.c [r3117] Changes to clean up compile warnings 2017-04-05 22:11:31 +02:00
bip6.c change ipv6 broadcast from BIP6_MULTICAST_SITE_LOCAL to BIP6_MULTICAST_GLOBAL interop with yabe 2016-10-30 23:19:30 +01:00
dlmstp_linux.c [r3138] Merged revision(s) 3136 from branches/releases/bacnet-stack-0-8-0: 2018-03-25 16:09:35 +02:00
dlmstp_linux.h [r3138] Merged revision(s) 3136 from branches/releases/bacnet-stack-0-8-0: 2018-03-25 16:09:35 +02:00
dlmstp.c update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
dlmstp.mak fork from http://sourceforge.net/projects/bacnet/ 2013-03-21 22:53:31 +01:00
ethernet.c update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
mstpsnap.c update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
mstpsnap.mak update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
net.h update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
readme.txt fork from http://sourceforge.net/projects/bacnet/ 2013-03-21 22:53:31 +01:00
rs485.c [r3066] Added Wireshark 2.x extcap live capture for mstpcap on Linux. 2016-11-01 19:29:15 +01:00
rs485.h update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
rs485.mak update to r3056 from https://sourceforge.net/p/bacnet/code/3056/tree/trunk/bacnet-stack/ add ipv6 and schedule support 2016-10-30 16:16:03 +01:00
rx_fsm.c fork from http://sourceforge.net/projects/bacnet/ 2013-03-21 22:53:31 +01:00
rx_fsm.mak fork from http://sourceforge.net/projects/bacnet/ 2013-03-21 22:53:31 +01:00
timer.c fork from http://sourceforge.net/projects/bacnet/ 2013-03-21 22:53:31 +01:00
timer.h fork from http://sourceforge.net/projects/bacnet/ 2013-03-21 22:53:31 +01:00

This is a port to Linux for testing.
The unit tests can be run via the test.sh script.