wb2osz / direwolf

Dire Wolf is a software "soundcard" AX.25 packet modem/TNC and APRS encoder/decoder. It can be used stand-alone to observe APRS traffic, as a tracker, digipeater, APRStt gateway, or Internet Gateway (IGate). For more information, look at the bottom 1/4 of this page and in https://github.com/wb2osz/direwolf/blob/dev/doc/README.md
GNU General Public License v2.0
1.51k stars 299 forks source link

Refactor dlq queueing and locking #496

Open bjpetit opened 8 months ago

bjpetit commented 8 months ago

I was digging into the dlq queueing code as I was trying to understand why I was getting these messages. Received frame queue is out of control. Length Upon some further digging, I believe the number of nodes my bpq instance registers may be triggering this message from time to time. That's why you'll see I bumped the message conditional to 15 in the change. While I was digging in, I ended up doing a little refactoring on the queueing and locking in this area. The key changes are;

I'm currently testing this against my bpq station on one HF FX.25 port, one HF IL2P port and one VHF FX.25 port, and so far things are holding together ok. One caveat: I haven't tried compiling or testing this against Windows as I don't have a windows system set up at the moment. But leaving this PR here, in case it is interesting.

wb2osz commented 8 months ago

Thank you for your suggestions to help clean up this mess. It was a long time ago, but I recall that it took some effort to get it working correctly on both Linux and Windows. As I recall, there was a difference in the behavior of semaphores. One one platform, they maintained a count, on the other they did not. My work around was to add another variable to indicate whether the queue reading thread was waiting on an empty queue. This might have something to do with two different mutexes, when you might expect one for all of the variables related to the queue maintenance. I need some time to study this.