ecere/net/dcom; samples/Blokus: Further robustness improvements to Distributed Objects
These were made to solve hard to reproduce problems found in Ecere Blokus.
Testing method involved two instances of Ecere Blokus sending out messages back and
forthat 10 Hz and random moves (on client's turn) at 20Hz, auto-restarting the game
on completion.
* Lockups / general messaging confusion when playing while messages are exchanged
- The bool answered approach was inadequate as another thread could try notifying
of an answer by setting it to true, but if reentrant was true, it would get reset
back to false. Replaced it by a safer implementation as a list of acknowledgements,
doing callID, methodID and objectID checks, so it can also handle if messages come
out of order. The acknowledgement objects include their buffer for returned values.
* Lockups occurring in deeper recursion from ServerSocket's OnReceivePacket
- In OnReceivePacket, saved packet data for later processing, at the top level
of the DCOMServerThread, in ProcessCalls()
* Mixups, wrong or bad method called back
- In DCOMClientObject's OnReceivePacket, ensured not to use callMethod object
after the method is called back, as it is the volatile packet data
(And OnReceivePacket might have been called back again, invalidating it)
* Blocks on client showing up in wrong color (Turn confusion)
* Another rare occurence when running tests, was a new GameStarted getting sent in
between two MovePlayed
- Ensured virtual methods for notifications are sent atomically, by introducing
the DCOMSendControl class to Stop/Resume sending while sending out notifications
to all clients.
* Messages something coming out empty (parameter corruption)
- Used two SerialBuffers instead of one for arguments/return values, as it could
have been used simultaneously by two threads.
Modified ecs to generate DCOM bindings using argsBuffer/returnBuffer.
* Lockup on Kick
- Unlocked GUI lock around Disconnect calls
* Crash at null Blokus on exit
- Added 'connected' check in DCOMClientObject's OnReceivePacket
- Moved connection to server from Communication Panel to Blokus Window
(Might not have been necessary... the connected fix seems to have been the fix,
but since virtual methods rely on Blokus, it seemed more appropriate)
* Stop Hosting would lock up after connect/disconnect on Linux
- Added a time out to Service::Process's select
(It seems the shutdown socket does not interrupt that socket...)
- Fixed Service's socket value check and assigned value to be -1 instead of 0