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

On 06/08/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  It turned out that PACKET_FREEZE_HINT / PACKET_THAW_HINT pair is used
> for two different purposes (and this doesn't work, of course).
>  When delta network code notices PACKET_FREEZE_HINT, it will not send
> anything until it notices PACKET_THAW_HINT. This includes
> PACKET_FREEZE_HINT itself.
>  Client uses PACKET_FREEZE_HINT / PACKET_THAW_HINT to freeze reports
> and such. Clearly at least some of the server side code is written for
> this use, and not to block all network traffic.

 For S2_1 we need backwards compatible solution. For trunk we have
better alternatives in the future. However, now I start by writing
that S2_1 style solution. Attached patch is for trunk. Actual S2_1
version needs some additional capability checks.
 This patch adds new packets PACKET_FREEZE_CLIENT and
PACKET_THAW_CLIENT. These are used instead of PACKET_FREEZE_HINT and
PACKET_THAW_HINT when we want client reports and agents to freeze
instead of buffering network traffic.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-08-05 16:40:59.000000000 +0300
+++ freeciv/client/packhand.c	2007-08-06 01:58:41.000000000 +0300
@@ -2902,11 +2902,19 @@
 }
 
 /**************************************************************************
-...
+  We have received PACKET_FREEZE_HINT. It is packet internal to network code
 **************************************************************************/
 void handle_freeze_hint(void)
 {
   freelog(LOG_DEBUG, "handle_freeze_hint");
+}
+
+/**************************************************************************
+  We have received PACKET_FREEZE_CLIENT.
+**************************************************************************/
+void handle_freeze_client(void)
+{
+  freelog(LOG_DEBUG, "handle_freeze_client");
 
   reports_freeze();
 
@@ -2914,11 +2922,19 @@
 }
 
 /**************************************************************************
-...
+  We have received PACKET_THAW_HINT. It is packet internal to network code
 **************************************************************************/
 void handle_thaw_hint(void)
 {
   freelog(LOG_DEBUG, "handle_thaw_hint");
+}
+
+/**************************************************************************
+  We have received PACKET_THAW_CLIENT
+**************************************************************************/
+void handle_thaw_client(void)
+{
+  freelog(LOG_DEBUG, "handle_thaw_client");
 
   reports_thaw();
 
diff -Nurd -X.diff_ignore freeciv/common/packets.c freeciv/common/packets.c
--- freeciv/common/packets.c	2007-08-04 18:38:32.000000000 +0300
+++ freeciv/common/packets.c	2007-08-06 02:06:43.000000000 +0300
@@ -119,6 +119,12 @@
       compression_level_initialized = TRUE;
     }
 
+    /* TODO: PACKET_FREEZE_HINT and PACKET_THAW_HINT are meaningful
+     * only internally. They should not be sent to connection at all.
+     * Freezing could also be handled via separate functions, and
+     * not by special packets.
+     * Only problem is backward compatibility, so this cannot be
+     * changed in stable branch. */
     if (packet_type == PACKET_PROCESSING_STARTED
 	|| packet_type == PACKET_FREEZE_HINT) {
       if (pc->compression.frozen_level == 0) {
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def	2007-08-04 18:38:32.000000000 +0300
+++ freeciv/common/packets.def	2007-08-06 01:54:37.000000000 +0300
@@ -1013,6 +1013,14 @@
   TURN turn;
 end
 
+# Freeze reports and agents
+PACKET_FREEZE_CLIENT=135;sc,lsend
+end
+
+# Thaw reports and agents
+PACKET_THAW_CLIENT=136;sc,lsend
+end
+
 /************** Spaceship packets **********************/
 
 PACKET_SPACESHIP_LAUNCH=93;cs
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c	2007-08-04 18:36:24.000000000 +0300
+++ freeciv/server/srv_main.c	2007-08-06 01:54:06.000000000 +0300
@@ -1682,10 +1682,10 @@
   /* 
    * This will freeze the reports and agents at the client.
    * 
-   * Do this before the body so that the PACKET_THAW_HINT packet is
+   * Do this before the body so that the PACKET_THAW_CLIENT packet is
    * balanced. 
    */
-  lsend_packet_freeze_hint(game.est_connections);
+  lsend_packet_freeze_client(game.est_connections);
 
   assert(server_state == RUN_GAME_STATE);
   while (server_state == RUN_GAME_STATE) {
@@ -1707,7 +1707,7 @@
       /* 
        * This will thaw the reports and agents at the client.
        */
-      lsend_packet_thaw_hint(game.est_connections);
+      lsend_packet_thaw_client(game.est_connections);
 
       /* Before sniff (human player activites), report time to now: */
       freelog(LOG_VERBOSE, "End/start-turn server/ai activities: %g seconds",
@@ -1742,7 +1742,7 @@
       /* 
        * This will freeze the reports and agents at the client.
        */
-      lsend_packet_freeze_hint(game.est_connections);
+      lsend_packet_freeze_client(game.est_connections);
 
       end_phase();
 
@@ -1764,7 +1764,7 @@
   }
 
   /* This will thaw the reports and agents at the client.  */
-  lsend_packet_thaw_hint(game.est_connections);
+  lsend_packet_thaw_client(game.est_connections);
 
   free_timer(eot_timer);
 }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to