]> git.pond.sub.org Git - empserver/commitdiff
Fix xdump updates not to dump bogus extra updates
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 30 Apr 2011 05:35:14 +0000 (07:35 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jun 2011 14:45:31 +0000 (16:45 +0200)
"xdump updates" believes there are always 15 (UPDATE_TIME_LEN - 1)
scheduled updates.  When fewer than 15 updates are scheduled, it shows
whatever crap update time happens to be in the unused part of
update_time[]: the initial zero or a previously scheduled update.

Root cause is that table EF_UPDATES has always UPDATE_TIME_LEN - 1
entries, which is incorrect when fewer updates are scheduled.  Only
xdump is affected, as the other users ignore the length and stop at
the sentinel.

Fix update_get_schedule() to resize table EF_UPDATES.

src/lib/common/filetable.c
src/server/update.c

index feed7c5f04fe077e4e3c316f8815cef99dfea9ea..70a049f529b7ac586d5f1004e2e17e33be470c86 100644 (file)
@@ -186,7 +186,7 @@ struct empfile empfile[] = {
      * Update schedule table.  Use read_schedule() to fill.
      */
     {EF_UPDATES, "updates", NULL, update_ca,
      * Update schedule table.  Use read_schedule() to fill.
      */
     {EF_UPDATES, "updates", NULL, update_ca,
-     ARRAY_TABLE(update_time, EFF_CFG)},
+     ARRAY_CACHE(update_time, EFF_CFG)},
     /*
      * Special tables.  EF_META gets bogus size, cids and fids here.
      * Fixed up by empfile_init().  EF_VERSION's cadef is set by
     /*
      * Special tables.  EF_META gets bogus size, cids and fids here.
      * Fixed up by empfile_init().  EF_VERSION's cadef is set by
index 20e31a7ac045f6753a8b2820994b56ddf92545ac..dd6f2acb39c4e929b411edc5c26fdc08e7add4d3 100644 (file)
@@ -41,6 +41,7 @@
 #endif
 #include <time.h>
 #include "empthread.h"
 #endif
 #include <time.h>
 #include "empthread.h"
+#include "file.h"
 #include "game.h"
 #include "misc.h"
 #include "optlist.h"
 #include "game.h"
 #include "misc.h"
 #include "optlist.h"
@@ -97,15 +98,20 @@ static int
 update_get_schedule(void)
 {
     time_t now = time(NULL);
 update_get_schedule(void)
 {
     time_t now = time(NULL);
+    int n = sizeof(update_time) / sizeof(*update_time);
+    int i;
 
 
-    if (read_schedule(schedulefil, update_time,
-                     sizeof(update_time) / sizeof(*update_time),
+    ef_truncate(EF_UPDATES, 0);
+    ef_extend(EF_UPDATES, n - 1);
+    if (read_schedule(schedulefil, update_time, n,
                      now + 30, update_schedule_anchor) < 0) {
        logerror("No update schedule!");
                      now + 30, update_schedule_anchor) < 0) {
        logerror("No update schedule!");
-       update_time[0] = 0;
+       ef_truncate(EF_UPDATES, 0);
        return -1;
     }
     logerror("Update schedule read");
        return -1;
     }
     logerror("Update schedule read");
+    for (i = 0; update_time[i]; i++) ;
+    ef_truncate(EF_UPDATES, i);
     return 0;
 }
 
     return 0;
 }