Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13817) pubserver crash with "/l" on chatline
Home

[Freeciv-Dev] (PR#13817) pubserver crash with "/l" on chatline

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13817) pubserver crash with "/l" on chatline
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Aug 2005 13:56:27 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch fixes the crash itself.  There may be other crashes caused by
this problem...or maybe not.

It also includes some sanitycheck code that removes unused conns from
the list.  This can't assert of course since that would defy the point.
 This probably shouldn't be committed though.  It's untested.

The patch is for 2.0.  I plan to commit the stdinhand.c bit shortly.

-jason



? mintimeout.diff.BROKEN
? mintimeout30.patch
? old_gamelog-6.diff
? utility/shared.o.mpnLgb
Index: server/sanitycheck.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sanitycheck.c,v
retrieving revision 1.53.2.2
diff -p -u -r1.53.2.2 sanitycheck.c
--- server/sanitycheck.c        25 May 2005 04:21:07 -0000      1.53.2.2
+++ server/sanitycheck.c        31 Aug 2005 20:53:50 -0000
@@ -419,6 +419,42 @@ static void check_players(void)
   }
 }
 
+/****************************************************************************
+  Trim unused connections off the list.
+****************************************************************************/
+static void trim_conn_list(struct conn_list *list)
+{
+  int toremove = 0, i;
+  struct connection *remove[conn_list_size(list)];
+
+  conn_list_iterate(*list, pconn) {
+    if (!pconn->used) {
+      remove[toremove] = pconn;
+      toremove++;
+    }
+  } conn_list_iterate_end;
+
+  for (i = 0; i < toremove; i++) {
+    conn_list_unlink(list, remove[i]);
+  }
+}
+
+/****************************************************************************
+  A bug that we haven't been able to trace leaves unused
+  connections on the lists.  This removes them.
+****************************************************************************/
+static void check_connections(void)
+{
+  /* This is a known bug so we don't crash the server.  Instead we just
+   * fix it.  This may lead to a memory leak. */
+  players_iterate(pplayer) {
+    trim_conn_list(&pplayer->connections);
+  } players_iterate_end;
+  trim_conn_list(&game.game_connections);
+  trim_conn_list(&game.est_connections);
+  trim_conn_list(&game.all_connections);
+}
+
 /**************************************************************************
 ...
 **************************************************************************/
@@ -435,6 +471,7 @@ void sanity_check(void)
   }
   check_misc();
   check_players();
+  check_connections();
 }
 
 #endif /* SANITY_CHECKING */
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.354.2.39
diff -p -u -r1.354.2.39 stdinhand.c
--- server/stdinhand.c  11 Aug 2005 04:43:55 -0000      1.354.2.39
+++ server/stdinhand.c  31 Aug 2005 20:53:52 -0000
@@ -4053,6 +4053,11 @@ void show_players(struct connection *cal
       cmd_reply(CMD_LIST, caller, C_COMMENT, "%s", buf);
       
       conn_list_iterate(pplayer->connections, pconn) {
+       if (!pconn->used) {
+         /* A bug that we haven't been able to trace leaves unused
+          * connections on the lists.  We skip them. */
+         continue;
+       }
        my_snprintf(buf, sizeof(buf),
                    _("  %s from %s (command access level %s), bufsize=%dkb"),
                    pconn->username, pconn->addr, 

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