Write an accurate value for the history count, so the progress bar is correct.
(cherry picked from commit 0919700293e34f5a93a4407d33e1e56c0ae0d13c)
This commit is contained in:
parent
dd734debc3
commit
e68949bdb3
|
@ -713,6 +713,7 @@ void backgroundTasks(void) {
|
||||||
|
|
||||||
if ((Modes.json_dir || Modes.net_http_port) && now >= next_history) {
|
if ((Modes.json_dir || Modes.net_http_port) && now >= next_history) {
|
||||||
char filebuf[PATH_MAX];
|
char filebuf[PATH_MAX];
|
||||||
|
int rewrite_receiver_json = (Modes.json_aircraft_history[HISTORY_SIZE-1].content == NULL);
|
||||||
|
|
||||||
free(Modes.json_aircraft_history[Modes.json_aircraft_history_next].content); // might be NULL, that's OK.
|
free(Modes.json_aircraft_history[Modes.json_aircraft_history_next].content); // might be NULL, that's OK.
|
||||||
Modes.json_aircraft_history[Modes.json_aircraft_history_next].content =
|
Modes.json_aircraft_history[Modes.json_aircraft_history_next].content =
|
||||||
|
@ -722,6 +723,10 @@ void backgroundTasks(void) {
|
||||||
writeJsonToFile(filebuf, generateHistoryJson);
|
writeJsonToFile(filebuf, generateHistoryJson);
|
||||||
|
|
||||||
Modes.json_aircraft_history_next = (Modes.json_aircraft_history_next+1) % HISTORY_SIZE;
|
Modes.json_aircraft_history_next = (Modes.json_aircraft_history_next+1) % HISTORY_SIZE;
|
||||||
|
|
||||||
|
if (rewrite_receiver_json)
|
||||||
|
writeJsonToFile("receiver.json", generateReceiverJson); // number of history entries changed
|
||||||
|
|
||||||
next_history = now + HISTORY_INTERVAL;
|
next_history = now + HISTORY_INTERVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -977,7 +982,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (Modes.net) modesInitNet();
|
if (Modes.net) modesInitNet();
|
||||||
|
|
||||||
writeJsonToFile("receiver.json", generateReceiverJson); // once only on startup
|
writeJsonToFile("receiver.json", generateReceiverJson); // once on startup
|
||||||
|
|
||||||
// If the user specifies --net-only, just run in order to serve network
|
// If the user specifies --net-only, just run in order to serve network
|
||||||
// clients without reading data from the RTL device
|
// clients without reading data from the RTL device
|
||||||
|
|
9
net_io.c
9
net_io.c
|
@ -737,14 +737,21 @@ char *generateAircraftJson(const char *url_path, int *len) {
|
||||||
char *generateReceiverJson(const char *url_path, int *len)
|
char *generateReceiverJson(const char *url_path, int *len)
|
||||||
{
|
{
|
||||||
char *buf = (char *) malloc(1024), *p = buf;
|
char *buf = (char *) malloc(1024), *p = buf;
|
||||||
|
int history_size;
|
||||||
|
|
||||||
(void)url_path; // unused
|
(void)url_path; // unused
|
||||||
|
|
||||||
|
// work out number of valid history entries
|
||||||
|
if (Modes.json_aircraft_history[HISTORY_SIZE-1].content == NULL)
|
||||||
|
history_size = Modes.json_aircraft_history_next;
|
||||||
|
else
|
||||||
|
history_size = HISTORY_SIZE;
|
||||||
|
|
||||||
p += sprintf(p, "{ " \
|
p += sprintf(p, "{ " \
|
||||||
"\"version\" : \"%s\", "
|
"\"version\" : \"%s\", "
|
||||||
"\"refresh\" : %d, "
|
"\"refresh\" : %d, "
|
||||||
"\"history\" : %d",
|
"\"history\" : %d",
|
||||||
MODES_DUMP1090_VERSION, Modes.json_interval * 1000, HISTORY_SIZE);
|
MODES_DUMP1090_VERSION, Modes.json_interval * 1000, history_size);
|
||||||
|
|
||||||
if (Modes.json_location_accuracy && (Modes.fUserLat != 0.0 || Modes.fUserLon != 0.0)) {
|
if (Modes.json_location_accuracy && (Modes.fUserLat != 0.0 || Modes.fUserLon != 0.0)) {
|
||||||
if (Modes.json_location_accuracy == 1) {
|
if (Modes.json_location_accuracy == 1) {
|
||||||
|
|
Loading…
Reference in a new issue