<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39582 >

> [EMAIL PROTECTED] - So 22. Jun 2008, 19:09:56]:
> 
> I can't reproduce the crash here with S2_0.  On loading the game and 
> ending turn a time or two, the game ends.  What client is used to get 
> the crash and what is necessary to do other than just end turn?
> 
> -jason
> 
> 

The crash happens on Windows (GTK+ client) after ending the turn and
after the server cuts the connection "due to lagging player" while the
client is busy for some seconds. When the client detects the lost
connection (in this case when trying to send data to the server in
request_new_unit_activity(punit, ACTIVITY_IDLE), called from
set_unit_focus()) it does some cleanup and switches to the main page.
But set_unit_focus() still continues after the
request_new_unit_activity() call and references a now invalid unit pointer:

/* in set_unit_focus() */

    ...

    if (punit->activity != ACTIVITY_IDLE || punit->ai.control)  {
      punit->ai.control = FALSE;
      refresh_unit_city_dialogs(punit);
      request_new_unit_activity(punit, ACTIVITY_IDLE);

      /**** lost connection detected and client in pre-game state ***/

    }
  }

  /**** punit_old_focus is now invalid *****/

  /* avoid the old focus unit disappearing: */
  if (punit_old_focus
      && (!punit || !same_pos(punit_old_focus->tile, punit->tile))) {
    refresh_tile_mapcanvas(punit_old_focus->tile, FALSE);
  }


Now I wonder if it's really necessary to take actions on socket write
errors on the client side at all? Since the request calls to the server
don't return an immediate result that the client depends on, wouldn't it
be sufficient if the client would cleanup and reset to pre-game state
only when reading of server input fails? The attached patch fixed the
crash and didn't show any problems for me so far.

Index: client/clinet.c
===================================================================
--- client/clinet.c	(revision 14833)
+++ client/clinet.c	(working copy)
@@ -186,8 +186,6 @@
 {
   struct packet_server_join_req req;
 
-  close_socket_set_callback(close_socket_callback);
-
   /* connection in progress? wait. */
   if (aconnection.used) {
     (void) mystrlcpy(errbuf, _("Connection in progress."), errbufsize);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to