Version 1.09.1607.14
Improvements to COAA MLAT functions Reduce CPU load in PPUP1090 and DUMP1090 during cleanup
This commit is contained in:
parent
8b05286a24
commit
845289ad9f
BIN
coaa1090.obj
BIN
coaa1090.obj
Binary file not shown.
Binary file not shown.
|
@ -37,7 +37,7 @@
|
||||||
// MinorVer changes when additional features are added, but not for bug fixes (range 00-99)
|
// 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
|
// 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 ==========================
|
// ============================= Include files ==========================
|
||||||
|
|
||||||
|
@ -229,6 +229,7 @@ struct aircraft {
|
||||||
|
|
||||||
struct stDF {
|
struct stDF {
|
||||||
struct stDF *pNext; // Pointer to next item in the linked list
|
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
|
struct aircraft *pAircraft; // Pointer to the Aircraft structure for this DF
|
||||||
time_t seen; // Dos/UNIX Time at which the this packet was received
|
time_t seen; // Dos/UNIX Time at which the this packet was received
|
||||||
uint64_t llTimestamp; // Timestamp 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
|
// Interactive mode
|
||||||
struct aircraft *aircrafts;
|
struct aircraft *aircrafts;
|
||||||
uint64_t interactive_last_update; // Last screen update in milliseconds
|
uint64_t interactive_last_update; // Last screen update in milliseconds
|
||||||
|
time_t last_cleanup_time; // Last cleanup time in seconds
|
||||||
|
|
||||||
// DF List mode
|
// DF List mode
|
||||||
int bEnableDFLogging; // Set to enable DF Logging
|
int bEnableDFLogging; // Set to enable DF Logging
|
||||||
|
|
|
@ -61,8 +61,10 @@ void interactiveCreateDF(struct aircraft *a, struct modesMessage *mm) {
|
||||||
memcpy(pDF->msg, mm->msg, MODES_LONG_MSG_BYTES);
|
memcpy(pDF->msg, mm->msg, MODES_LONG_MSG_BYTES);
|
||||||
|
|
||||||
if (!pthread_mutex_lock(&Modes.pDF_mutex)) {
|
if (!pthread_mutex_lock(&Modes.pDF_mutex)) {
|
||||||
pDF->pNext = Modes.pDF;
|
if ((pDF->pNext = Modes.pDF)) {
|
||||||
Modes.pDF = pDF;
|
Modes.pDF->pPrev = pDF;
|
||||||
|
}
|
||||||
|
Modes.pDF = pDF;
|
||||||
pthread_mutex_unlock(&Modes.pDF_mutex);
|
pthread_mutex_unlock(&Modes.pDF_mutex);
|
||||||
} else {
|
} else {
|
||||||
free(pDF);
|
free(pDF);
|
||||||
|
@ -83,7 +85,7 @@ void interactiveRemoveStaleDF(time_t now) {
|
||||||
pDF = Modes.pDF;
|
pDF = Modes.pDF;
|
||||||
while(pDF) {
|
while(pDF) {
|
||||||
if ((now - pDF->seen) > Modes.interactive_delete_ttl) {
|
if ((now - pDF->seen) > Modes.interactive_delete_ttl) {
|
||||||
if (!prev) {
|
if (Modes.pDF == pDF) {
|
||||||
Modes.pDF = NULL;
|
Modes.pDF = NULL;
|
||||||
} else {
|
} else {
|
||||||
prev->pNext = NULL;
|
prev->pNext = NULL;
|
||||||
|
@ -91,14 +93,13 @@ void interactiveRemoveStaleDF(time_t now) {
|
||||||
|
|
||||||
// All DF's in the list from here onwards will be time
|
// All DF's in the list from here onwards will be time
|
||||||
// expired, so delete them all
|
// expired, so delete them all
|
||||||
while ((prev = pDF)) {
|
while (pDF) {
|
||||||
pDF = pDF->pNext;
|
prev = pDF; pDF = pDF->pNext;
|
||||||
free(prev);
|
free(prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
prev = pDF;
|
prev = pDF; pDF = pDF->pNext;
|
||||||
pDF = pDF->pNext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock (&Modes.pDF_mutex);
|
pthread_mutex_unlock (&Modes.pDF_mutex);
|
||||||
|
@ -533,25 +534,24 @@ void interactiveRemoveStaleAircrafts(void) {
|
||||||
struct aircraft *prev = NULL;
|
struct aircraft *prev = NULL;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
interactiveRemoveStaleDF(now);
|
// Only do cleanup once per second
|
||||||
|
if (Modes.last_cleanup_time != now) {
|
||||||
|
Modes.last_cleanup_time = now;
|
||||||
|
|
||||||
while(a) {
|
interactiveRemoveStaleDF(now);
|
||||||
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) {
|
while(a) {
|
||||||
Modes.aircrafts = next;
|
if ((now - a->seen) > Modes.interactive_delete_ttl) {
|
||||||
|
// Remove the element from the linked list, with care
|
||||||
|
// if we are removing the first element
|
||||||
|
if (!prev) {
|
||||||
|
Modes.aircrafts = a->next; free(a); a = Modes.aircrafts;
|
||||||
|
} else {
|
||||||
|
prev->next = a->next; free(a); a = prev->next;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
prev->next = next;
|
prev = a; a = a->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(a);
|
|
||||||
a = next;
|
|
||||||
} else {
|
|
||||||
prev = a;
|
|
||||||
a = a->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
mode_s.c
1
mode_s.c
|
@ -2044,7 +2044,6 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
|
||||||
surface_rlat = Modes.fUserLat;
|
surface_rlat = Modes.fUserLat;
|
||||||
surface_rlon = Modes.fUserLon;
|
surface_rlon = Modes.fUserLon;
|
||||||
} else {
|
} else {
|
||||||
surface_rlat = Modes.fUserLat;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rlat0 += floor(surface_rlat / 90.0) * 90.0; // Move from 1st quadrant to our quadrant
|
rlat0 += floor(surface_rlat / 90.0) * 90.0; // Move from 1st quadrant to our quadrant
|
||||||
|
|
|
@ -208,7 +208,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Try to comply with the Copyright license conditions for binary distribution
|
// Try to comply with the Copyright license conditions for binary distribution
|
||||||
if (!Modes.quiet) {showCopyright();}
|
if (!ppup1090.quiet) {showCopyright();}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
Loading…
Reference in a new issue