Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: Attribute.c fixes (PR#1217)
Home

[Freeciv-Dev] Re: Attribute.c fixes (PR#1217)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Attribute.c fixes (PR#1217)
From: Teemu Kurppa <tkurppa@xxxxxxxxxx>
Date: Thu, 10 Jan 2002 01:45:29 -0800 (PST)

On Thu, 10 Jan 2002, Teemu Kurppa wrote:
> Attributes are also flushed, when client disconnects, but doesn't quit. 
  
For some reason, this addition causes assert failure in following scenario:

+++++++++++++++++++++++++
configure with --enable-debug
set TEST_ATTRIBUTES 1 in packhand.c
compile

run server
run client and connect
start game and choose nation
move one unit
disconnect from menu (don't quit yet!)
quit by pressing quit button in connect dialog.

run client and reconnect

civclient: packhand.c:92: attach_test_attribute: Assertion `buffer[i] == 
foobar(unit_id, i)' failed.
Aborted (core dumped)
*************************
                                                           
Recent additition to cvs was to flush attributes when client quits:  
**************************
diff -Nur -X patches/diff_ignore cvs-freeciv/client/civclient.c 
work-freeciv/client/civclient.c
--- cvs-freeciv/client/civclient.c      Thu Jan  3 17:02:10 2002
+++ work-freeciv/client/civclient.c     Tue Jan  8 19:21:34 2002
@@ -189,7 +189,7 @@
   ui_main(argc, argv);
 
   /* termination */
-
+  attribute_flush();
   my_shutdown_network();
 
   return 0;             
**************************

Patch adds: 
*************************
diff -Nur -X patches/diff_ignore cvs-freeciv/client/clinet.c 
work-freeciv/client/clinet.c
--- cvs-freeciv/client/clinet.c Thu Dec 13 22:05:32 2001
+++ work-freeciv/client/clinet.c        Thu Jan 10 09:46:29 2002
@@ -68,6 +68,7 @@
 #include "version.h"
 #include "hash.h"
 
+#include "attribute.h"
 #include "chatline_g.h"
 #include "civclient.h"
 #include "dialogs_g.h"         /* popdown_races_dialog() */
@@ -239,6 +240,7 @@
 void disconnect_from_server(void)
 {
   append_output_window(_("Disconnecting from server."));
+  attribute_flush();
   close_socket_nomessage(&aconnection);
 }
*************************

Okay, if I unterstand the situation correctly: obviously in this case
attribute_flush is done twice. At the second time connection to the server
is closed. However something gets send and it breaks integrity of
attributes in the server side. 

Everything seems to work, if attribute_flush is left out in 
disconnect_from_server. I'll look on this further, once I get other things
done. 

Btw, is there some cleanup function that is called in both cases: when
client only disconnects from game or quits. I didn't find. If there's not 
such function, we probably should introduce one. 

Teemu Kurppa




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