Post new topic Reply to topic  [ 3 posts ] 
Debug + lag simulation + client disc = server crash 
Author Message

Joined: Fri Oct 30, 2009 9:02 pm
Posts: 5
Post Debug + lag simulation + client disc = server crash
Hey again!

I've been working on a RTS game that uses ZoidCom for a few months already. Thing is, today I just got a strange bug and I switched to debug mode and to my surprise the server seemed to crash everytime the client disconnected. So I just forgot about that bug, and I focused on finding what was causing those crashes. Strangely enough, there were no crashes when building on release, and I hadn't had any issues previously on debug either.

The server log when crashing is:
Code:
Server running and listening on udp port: 8899.
[ZCOM_SRV]: inserting node of class [ZC0M]
[ZCOM_SRV]: incoming connection request from UDP: 127.0.0.1:59750 (control id: 0)
Someone wants to connect!
[ZCOM_SRV]: new outgoing bandwidth for 1: 200 bpp / 15 pps
Someone has connected!
Number of connections now: 1
[ZCOM_SRV/1]: received zoidlevel request for level: 1
Client requesting to enter Zoidlevel: 1
[ZCOM_SRV/1]: zoidrequest accepted by application
[ZCOM_SRV/1] requesting sync for node: [1]
Client entered Zoidlevel: 1
[ZCOM_SRV]: inserting node of class [Player]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV]: inserting node of class [Unitat]
[ZCOM_SRV/1]: peer announced disconnect
A connection has closed!
Number of connections now: 0
[ZCOM_SRV]: new outgoing bandwidth for 1: 200 bpp / 15 pps
[ZCOM_SRV]: deleting node with network id: 1 [class: ZC0M][local id: 1]
Asymmetrical read detected - wrong type: 0, expected: 2


After commenting code for a few hours I ended up with just the bare minimum on the server side, with just the connection code. I was really going mad as nothing seemed to help. But then I tried not calling ZCom_simulateLag and the assertions dissapeared.

Here's the server's process main loop:
Code:
   Server *srv = new Server( 1, 8899 );

   unsigned int timeini, loops = 0;
   timeini = ZoidCom::getTime();
   while (1)
   {
      srv->ZCom_simulateLag(0, 200 + rand() % 200);
      srv->ZCom_processInput( eZCom_NoBlock );
      srv->ZCom_processOutput();

      // pause the program for a few milliseconds
      int sleepTime = loops*10 - (ZoidCom::getTime() - timeini);
      if(sleepTime > 0) ZoidCom::Sleep(sleepTime);
      loops++;

      srv->actualitzar();
   }


The assertions happened on the call to ZCom_processInput just after the client disconnection. Also they just happened when calling ZCom_Control::ZCom_disconnectAll(NULL); on the client. There were no problems if the connection timed out either.

I'm just so shocked that I decided to post here and see what you thought about it. Some extra info: I'm using ZoidCom 6.11 and Visual Studio 2008.

Oh, and thanks for the amazing work on the library! ;)


Mon Mar 08, 2010 6:41 pm
Profile
Site Admin
User avatar

Joined: Thu Jan 29, 2004 6:33 am
Posts: 1060
Post Re: Debug + lag simulation + client disc = server crash
That might be because you change the lag every cycle, effectively reordering the packets. Normally this is no problem, but if the client sends some normal packets after a disconnect packet, the server tries to read it as a new connection packet, which it is not, and thus you get the assertion because the packet does not contain what the server expects.

This is only a problem in debug mode since the bitstream class asserts on asymmetric reads. In release mode the packet is silently dropped, which is the right thing to do.

To circumvent this you should make sure that the disconnect packet gets sent last, so set a very high simulate lag (higher than ever before(TM)) right before disconnecting and don't change it until you reconnect later.

_________________
Zoidcom 0.6.10 | Check out the new Zoidcom Wiki


Mon Mar 08, 2010 9:21 pm
Profile

Joined: Fri Oct 30, 2009 9:02 pm
Posts: 5
Post Re: Debug + lag simulation + client disc = server crash
I had already tried modifing the call to look as this: srv->ZCom_simulateLag(0, 200). Any disordering problems should be solved, but the server still crashes.

On a side note, I've seen a post of yours asking for suggestions. So why not improving that function to support a fluctuating lag simulation? I guess u could do better than just adding a rand() as I was doing as a quick fix.


Tue Mar 09, 2010 6:41 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

{ ASACP_CREDITS } Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forum/DivisionCore.