From 1b1f9de119730e8fb69e931ee53ea0b57f2039b1 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sun, 7 Feb 2021 22:22:01 +0800 Subject: [PATCH 1/3] Increase default stats json buffer size to 8k. Retry with a larger buffer if we run out of space, like we do with aircraft.json With the addition of the per-DF stats, the stats output started to exceed 4k in some cases (notably, you need --net turned on). Fixes #106 --- net_io.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/net_io.c b/net_io.c index d482998..8cb1e28 100644 --- a/net_io.c +++ b/net_io.c @@ -1828,15 +1828,20 @@ static char * appendStatsJson(char *p, } char *generateStatsJson(const char *url_path, int *len) { - const size_t bufsize = 4096; - char *buf = malloc(bufsize), *p = buf, *end = buf + bufsize; - if (!buf) { + MODES_NOTUSED(url_path); + + int buflen = 8192; + char *buf, *p, *end; + + retry: + if (!(buf = malloc(buflen))) { // allocation failed, give up *len = 0; return NULL; } - MODES_NOTUSED(url_path); + p = buf; + end = buf + buflen; p = safe_snprintf(p, end, "{\n"); p = appendStatsJson(p, end, &Modes.stats_latest, "latest"); @@ -1854,12 +1859,15 @@ char *generateStatsJson(const char *url_path, int *len) { p = appendStatsJson(p, end, &Modes.stats_alltime, "total"); p = safe_snprintf(p, end, "\n}\n"); - if (p <= end) { - *len = p-buf; - } else { - *len = 0; // ran out of buffer space, give up + int used = p - buf; + if (p >= end) { + // overran the buffer + buflen = used + 50; + free(buf); + goto retry; } + *len = used; return buf; } From 4ad6c7b4d3bf2c8ced047b8848ac43018ed46b29 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 8 Feb 2021 23:55:57 +0800 Subject: [PATCH 2/3] Disable non-generic starch build on stretch/jessie --- debian-jessie/rules | 4 +++- debian-stretch/rules | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian-jessie/rules b/debian-jessie/rules index f03be8a..3072b00 100755 --- a/debian-jessie/rules +++ b/debian-jessie/rules @@ -15,7 +15,9 @@ DPKG_EXPORT_BUILDFLAGS = 1 include /usr/share/dpkg/default.mk override_dh_auto_build: - dh_auto_build -- RTLSDR=yes BLADERF=yes HACKRF=no LIMESDR=no DUMP1090_VERSION=$(DEB_VERSION) + # jessie's gcc doesn't support the compiler flags needed for ARM-specific starch flavors; + # turn off runtime CPU detection + dh_auto_build -- RTLSDR=yes BLADERF=yes HACKRF=no LIMESDR=no DUMP1090_VERSION=$(DEB_VERSION) CPUFEATURES=no override_dh_install: dh_install diff --git a/debian-stretch/rules b/debian-stretch/rules index f03be8a..98002a2 100755 --- a/debian-stretch/rules +++ b/debian-stretch/rules @@ -15,7 +15,9 @@ DPKG_EXPORT_BUILDFLAGS = 1 include /usr/share/dpkg/default.mk override_dh_auto_build: - dh_auto_build -- RTLSDR=yes BLADERF=yes HACKRF=no LIMESDR=no DUMP1090_VERSION=$(DEB_VERSION) + # starch's gcc doesn't support the compiler flags needed for ARM-specific starch flavors; + # turn off runtime CPU detection + dh_auto_build -- RTLSDR=yes BLADERF=yes HACKRF=no LIMESDR=no DUMP1090_VERSION=$(DEB_VERSION) CPUFEATURES=no override_dh_install: dh_install From d8cca659e731056c8add8f8b7c256c78780e7b53 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Tue, 9 Feb 2021 00:30:25 +0800 Subject: [PATCH 3/3] Remove stray extra cpufeatures makefile include --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 75195b4..0ba6bf1 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,6 @@ endif UNAME := $(shell uname) ifeq ($(UNAME), Linux) - include Makefile.cpufeatures CPPFLAGS += -D_DEFAULT_SOURCE LIBS += -lrt LIBS_USB += -lusb-1.0