Version 1.09.1607.14

Improvements to COAA MLAT functions
Reduce CPU load in PPUP1090 and DUMP1090 during cleanup
This commit is contained in:
Malcolm Robb 2014-07-16 16:34:42 +01:00
parent 8b05286a24
commit 845289ad9f
6 changed files with 32 additions and 31 deletions

Binary file not shown.

View file

@ -37,7 +37,7 @@
// MinorVer changes when additional features are added, but not for bug fixes (range 00-99)
// DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update
//
#define MODES_DUMP1090_VERSION "1.09.1007.14"
#define MODES_DUMP1090_VERSION "1.09.1607.14"
// ============================= Include files ==========================
@ -229,6 +229,7 @@ struct aircraft {
struct stDF {
struct stDF *pNext; // Pointer to next item in the linked list
struct stDF *pPrev; // Pointer to previous item in the linked list
struct aircraft *pAircraft; // Pointer to the Aircraft structure for this DF
time_t seen; // Dos/UNIX Time at which the this packet was received
uint64_t llTimestamp; // Timestamp at which the this packet was received
@ -325,6 +326,7 @@ struct { // Internal state
// Interactive mode
struct aircraft *aircrafts;
uint64_t interactive_last_update; // Last screen update in milliseconds
time_t last_cleanup_time; // Last cleanup time in seconds
// DF List mode
int bEnableDFLogging; // Set to enable DF Logging

View file

@ -61,7 +61,9 @@ void interactiveCreateDF(struct aircraft *a, struct modesMessage *mm) {
memcpy(pDF->msg, mm->msg, MODES_LONG_MSG_BYTES);
if (!pthread_mutex_lock(&Modes.pDF_mutex)) {
pDF->pNext = Modes.pDF;
if ((pDF->pNext = Modes.pDF)) {
Modes.pDF->pPrev = pDF;
}
Modes.pDF = pDF;
pthread_mutex_unlock(&Modes.pDF_mutex);
} else {
@ -83,7 +85,7 @@ void interactiveRemoveStaleDF(time_t now) {
pDF = Modes.pDF;
while(pDF) {
if ((now - pDF->seen) > Modes.interactive_delete_ttl) {
if (!prev) {
if (Modes.pDF == pDF) {
Modes.pDF = NULL;
} else {
prev->pNext = NULL;
@ -91,14 +93,13 @@ void interactiveRemoveStaleDF(time_t now) {
// All DF's in the list from here onwards will be time
// expired, so delete them all
while ((prev = pDF)) {
pDF = pDF->pNext;
while (pDF) {
prev = pDF; pDF = pDF->pNext;
free(prev);
}
} else {
prev = pDF;
pDF = pDF->pNext;
prev = pDF; pDF = pDF->pNext;
}
}
pthread_mutex_unlock (&Modes.pDF_mutex);
@ -533,25 +534,24 @@ void interactiveRemoveStaleAircrafts(void) {
struct aircraft *prev = NULL;
time_t now = time(NULL);
// Only do cleanup once per second
if (Modes.last_cleanup_time != now) {
Modes.last_cleanup_time = now;
interactiveRemoveStaleDF(now);
while(a) {
if ((now - a->seen) > Modes.interactive_delete_ttl) {
struct aircraft *next = a->next;
// Remove the element from the linked list, with care
// if we are removing the first element
if (!prev) {
Modes.aircrafts = next;
Modes.aircrafts = a->next; free(a); a = Modes.aircrafts;
} else {
prev->next = next;
prev->next = a->next; free(a); a = prev->next;
}
free(a);
a = next;
} else {
prev = a;
a = a->next;
prev = a; a = a->next;
}
}
}
}

View file

@ -2044,7 +2044,6 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
surface_rlat = Modes.fUserLat;
surface_rlon = Modes.fUserLon;
} else {
surface_rlat = Modes.fUserLat;
return;
}
rlat0 += floor(surface_rlat / 90.0) * 90.0; // Move from 1st quadrant to our quadrant

View file

@ -208,7 +208,7 @@ int main(int argc, char **argv) {
#ifdef _WIN32
// Try to comply with the Copyright license conditions for binary distribution
if (!Modes.quiet) {showCopyright();}
if (!ppup1090.quiet) {showCopyright();}
#endif
// Initialization