usmanatron / amBXPeripheralController

Server application (with a number of assisting clients) to control amBX gaming peripherals
Other
2 stars 4 forks source link

Server freezes after pushing event #10

Closed usmanatron closed 10 years ago

usmanatron commented 10 years ago

Currently exhibiting itself on my work machine. Not sure if this is due to old code or not (shouldn't be as it's built on the newest version? That said haven't seen it anywhere else)

usmanatron commented 10 years ago

This is a weird one - definitely fine on my dev machine. Possibly just using an out-of-date release on my work machine? Newly added logging should help here at least.

usmanatron commented 10 years ago

Ok, found the problem (and it's reproducible). If you're running as desync and push an event, it doesn't then restart the desync components again (=> server freezes).

Worth noting a similar problem - if you're running sync and you push a desync scene (i.e. move from sync -> desync), then the lights stop updating but the desync block doesn't start. If you push it again it's fine

usmanatron commented 10 years ago

Problem is two-fold:

First is a race condition. What happens is:

  1. We get the snapshot out
  2. A separate thread updates the scene and ticker (so the snapshot is from a different scene!)
  3. The previous thread updates the ticker

So, we update a ticker which doesn't connect with the current snapshot. The end result is that we skip the first frame. For ccnet_green, there's only one frame, so this means nothing happens!

Solution: The current locking around all this is inadequate - need to reformulate.

A second problem is what happens when you go from desync scene -> event -> back to desync scene. Say you're running ccnet_green. As there's one frame, the conductors switch off. After the event, the ticker still reflects the previous state (i.e. it's finished, nothing to do). So nothing happens.

Solution: Need to reset the ticker when we re-enable the conductor

usmanatron commented 10 years ago

Fix committed (and seems to work fine): 1182ffa0