Fix xdump updates not to dump bogus extra updates
"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.
This commit is contained in:
parent
5b9d31a4b3
commit
573d3fe870
2 changed files with 10 additions and 4 deletions
|
@ -186,7 +186,7 @@ struct empfile empfile[] = {
|
||||||
* Update schedule table. Use read_schedule() to fill.
|
* Update schedule table. Use read_schedule() to fill.
|
||||||
*/
|
*/
|
||||||
{EF_UPDATES, "updates", NULL, update_ca,
|
{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.
|
* Special tables. EF_META gets bogus size, cids and fids here.
|
||||||
* Fixed up by empfile_init(). EF_VERSION's cadef is set by
|
* Fixed up by empfile_init(). EF_VERSION's cadef is set by
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "empthread.h"
|
#include "empthread.h"
|
||||||
|
#include "file.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
@ -97,15 +98,20 @@ static int
|
||||||
update_get_schedule(void)
|
update_get_schedule(void)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
int n = sizeof(update_time) / sizeof(*update_time);
|
||||||
|
int i;
|
||||||
|
|
||||||
if (read_schedule(schedulefil, update_time,
|
ef_truncate(EF_UPDATES, 0);
|
||||||
sizeof(update_time) / sizeof(*update_time),
|
ef_extend(EF_UPDATES, n - 1);
|
||||||
|
if (read_schedule(schedulefil, update_time, n,
|
||||||
now + 30, update_schedule_anchor) < 0) {
|
now + 30, update_schedule_anchor) < 0) {
|
||||||
logerror("No update schedule!");
|
logerror("No update schedule!");
|
||||||
update_time[0] = 0;
|
ef_truncate(EF_UPDATES, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
logerror("Update schedule read");
|
logerror("Update schedule read");
|
||||||
|
for (i = 0; update_time[i]; i++) ;
|
||||||
|
ef_truncate(EF_UPDATES, i);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue