hbeni/fgcom-mumble

Bug: playback bot does not kill itself after sample was deleted from disk

Closed this issue · 2 comments

hbeni commented

Describe the bug
The playback bot should kill itself if it tries to reread it's sample file but it was deleted.
This condition is detected well, but not executed in shutdownBot(); currently he runs on forever.

shutdownBot = function()
fgcom.log("shutdownBot(): requested")
updateAllChannelUsersforSend(client)
-- send update to mute our radio
-- TODO: send deregister request, once implemented
local msg = "FRQ="..lastHeader.frequency
..",CHN="..lastHeader.dialedFRQ
..",PWR="..lastHeader.txpower
..",PTT=0"
client:sendPluginData("FGCOM:UPD_COM:0:0", msg, playback_targets)
fgcom.log("shutdownBot(): COM0 deactiated")
-- finally disconnect from the server
client:disconnect()
fgcom.log("shutdownBot(): disconnected")
os.exit(0)
end

To Reproduce
Steps to reproduce the behavior:

  1. Start a new ATIS recording
  2. delete the generated FGCS sample file
  3. Observe the bot surviving

Expected behavior
Playback-bot should kill itself in shutdownBot(), but it somehow hangs in that function...

Logfiles

transmit next sample
  eos=true
  cdc=4
  dta=160
transmit ok
no samples left, playback complete
playback timer: tick
Looped timer: update voice buffer from file
'./recordings/fgcom.rec.ZZZZ-123.4500.fgcs' not readable or no FGCS file, probably deleted from filesystem.
shutdownBot(): requested
playback timer: tick
playback timer: tick
playback timer: tick
playback timer: tick
hbeni commented

Hm, could this potentially be linked to the addition where the API was switched to blocking calls?
It somehow behaves similar to the thread blocking issues I had some time ago.

Specifically it seems to be blocking when calling client:sendPluginData in the shutdown function.
The call to updateAllChannelUsersforSend() does succeed and return, as one can easily see when adding another log statement.


An easy quick-and-dirty fix is to shutdown hard at the beginning of the function, but that leads to stale data in the clients (which will be removed when the client side garbage collector kicks in; but thats not an ideal fix):

shutdownBot = function()
    fgcom.log("shutdownBot(): requested")
    updateAllChannelUsersforSend(client)
    os.exit(0)
    ...
hbeni commented

What is really strange is, that this only happens in the case where the file gets deleted from disk.
The other cases terminate quite nicely!

It even terminates nicely when adding shutdownBot() in front of the if check for the lastHeader.