Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] (PR#14305) Client crash on /endgame
Home

[Freeciv-Dev] (PR#14305) Client crash on /endgame

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#14305) Client crash on /endgame
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 5 Dec 2005 20:37:24 -0800
Reply-to: bugs@xxxxxxxxxxx

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

Rather than your first patch, I think we should use this one.  It moves
the freeze/thaw level check into the server.  This way when there's a
bug we can actually track it down.

-jason

Index: server/srv_main.c
===================================================================
--- server/srv_main.c   (revision 11311)
+++ server/srv_main.c   (working copy)
@@ -1574,7 +1574,7 @@
    * Do this before the body so that the PACKET_THAW_HINT packet is
    * balanced. 
    */
-  lsend_packet_freeze_hint(game.est_connections);
+  send_freeze_hint(NULL);
 
   assert(server_state == RUN_GAME_STATE);
   while (server_state == RUN_GAME_STATE) {
@@ -1596,7 +1596,7 @@
       /* 
        * This will thaw the reports and agents at the client.
        */
-      lsend_packet_thaw_hint(game.est_connections);
+      send_thaw_hint(NULL);
 
       /* Before sniff (human player activites), report time to now: */
       freelog(LOG_VERBOSE, "End/start-turn server/ai activities: %g seconds",
@@ -1636,7 +1636,7 @@
       /* 
        * This will freeze the reports and agents at the client.
        */
-      lsend_packet_freeze_hint(game.est_connections);
+      send_freeze_hint(NULL);
 
       end_phase();
 
@@ -1900,9 +1900,9 @@
     } players_iterate_end;
   }
 
-  lsend_packet_freeze_hint(game.est_connections);
+  send_freeze_hint(NULL);
   send_all_info(game.est_connections);
-  lsend_packet_thaw_hint(game.est_connections);
+  send_thaw_hint(NULL);
   
   if(game.info.is_new_game) {
     init_new_game();
Index: server/connecthand.c
===================================================================
--- server/connecthand.c        (revision 11308)
+++ server/connecthand.c        (working copy)
@@ -128,12 +128,12 @@
     if (server_state == RUN_GAME_STATE) {
       /* Player and other info is only updated when the game is running.
        * See the comment in lost_connection_to_client(). */
-      send_packet_freeze_hint(pconn);
+      send_freeze_hint(pconn->self);
       send_all_info(dest);
       send_game_state(dest, CLIENT_GAME_RUNNING_STATE);
       send_player_info(NULL,NULL);
       send_diplomatic_meetings(pconn);
-      send_packet_thaw_hint(pconn);
+      send_thaw_hint(pconn->self);
       dsend_packet_start_phase(pconn, game.info.phase);
     }
 
@@ -671,6 +671,41 @@
   send_conn_info_arg(src, dest, TRUE);
 }
 
+/****************************************************************************
+
+****************************************************************************/
+void send_thaw_hint(struct conn_list *dest)
+{
+  if (!dest) {
+    dest = game.est_connections;
+  }
+
+  conn_list_iterate(dest, pconn) {
+    if (pconn->server.frozen_level > 0) {
+      pconn->server.frozen_level--;
+      send_packet_thaw_hint(pconn);
+    } else {
+      freelog(LOG_ERROR, "Error: extra thaw hint sent to connection!");
+      assert(0);
+    }
+  } conn_list_iterate_end;
+}
+
+/****************************************************************************
+
+****************************************************************************/
+void send_freeze_hint(struct conn_list *dest)
+{
+  if (!dest) {
+    dest = game.est_connections;
+  }
+
+  conn_list_iterate(dest, pconn) {
+    pconn->server.frozen_level++;
+    send_packet_freeze_hint(pconn);
+  } conn_list_iterate_end;
+}
+
 /**************************************************************************
   Setup pconn as a client connected to pplayer:
   Updates pconn->player, pplayer->connections, pplayer->is_connected.
Index: server/connecthand.h
===================================================================
--- server/connecthand.h        (revision 11308)
+++ server/connecthand.h        (working copy)
@@ -33,6 +33,9 @@
 void send_conn_info(struct conn_list *src, struct conn_list *dest);
 void send_conn_info_remove(struct conn_list *src, struct conn_list *dest);
 
+void send_thaw_hint(struct conn_list *dest);
+void send_freeze_hint(struct conn_list *dest);
+
 bool attach_connection_to_player(struct connection *pconn, 
                                  struct player *pplayer);
 bool unattach_connection_from_player(struct connection *pconn);
Index: server/ruleset.c
===================================================================
--- server/ruleset.c    (revision 11308)
+++ server/ruleset.c    (working copy)
@@ -38,6 +38,7 @@
 #include "unit.h"
 
 #include "citytools.h"
+#include "connecthand.h"
 #include "plrhand.h"
 #include "script.h"
 
@@ -3082,7 +3083,7 @@
 void send_rulesets(struct conn_list *dest)
 {
   conn_list_do_buffer(dest);
-  lsend_packet_freeze_hint(dest);
+  send_freeze_hint(dest);
 
   send_ruleset_control(dest);
   send_ruleset_game(dest);
@@ -3096,6 +3097,6 @@
   send_ruleset_cities(dest);
   send_ruleset_cache(dest);
 
-  lsend_packet_thaw_hint(dest);
+  send_thaw_hint(dest);
   conn_list_do_unbuffer(dest);
 }
Index: server/sernet.c
===================================================================
--- server/sernet.c     (revision 11308)
+++ server/sernet.c     (working copy)
@@ -817,6 +817,7 @@
       pconn->server.ping_timers =
          fc_malloc(sizeof(*pconn->server.ping_timers));
       pconn->server.ping_timers = timer_list_new();
+      pconn->server.frozen_level = 0;
       pconn->ping_time = -1.0;
       pconn->incoming_packet_notify = NULL;
       pconn->outgoing_packet_notify = NULL;
Index: server/stdinhand.c
===================================================================
--- server/stdinhand.c  (revision 11308)
+++ server/stdinhand.c  (working copy)
@@ -2804,12 +2804,12 @@
   send_conn_info(pconn->self, game.est_connections);
 
   if (server_state == RUN_GAME_STATE) {
-    send_packet_freeze_hint(pconn);
+    send_freeze_hint(pconn->self);
     send_all_info(pconn->self);
     send_game_state(pconn->self, CLIENT_GAME_RUNNING_STATE);
     send_player_info(NULL, NULL);
     send_diplomatic_meetings(pconn);
-    send_packet_thaw_hint(pconn);
+    send_thaw_hint(pconn->self);
     dsend_packet_start_phase(pconn, game.info.phase);
   }
 
@@ -2966,12 +2966,12 @@
 
 
   if (server_state == RUN_GAME_STATE) {
-    send_packet_freeze_hint(pconn);
+    send_freeze_hint(pconn->self);
     send_all_info(pconn->self);
     send_game_state(pconn->self, CLIENT_GAME_RUNNING_STATE);
     send_player_info(NULL, NULL);
     send_diplomatic_meetings(pconn);
-    send_packet_thaw_hint(pconn);
+    send_thaw_hint(pconn->self);
     dsend_packet_start_phase(pconn, game.info.phase);
   }
 
Index: common/connection.h
===================================================================
--- common/connection.h (revision 11308)
+++ common/connection.h (working copy)
@@ -199,6 +199,9 @@
 
     /* for reverse lookup and blacklisting in db */
     char ipaddr[MAX_LEN_ADDR];
+
+    /* Number of freeze hints sent (for sanity). */
+    int frozen_level;
   } server;
 
   /*

[Prev in Thread] Current Thread [Next in Thread]