Skip maintaining filter wx and entrycall tables if no filtered listeners enabled

This commit is contained in:
Heikki Hannikainen 2020-09-06 15:01:42 +03:00
parent c7acfe75f4
commit f8eaf0fdbd
5 changed files with 11 additions and 8 deletions

View File

@ -1475,8 +1475,8 @@ void accept_thread(void *asdf)
n++;
}
hlog(LOG_INFO, "Accept thread ready.");
historydb_enabled = has_filtered_listeners_now;
if (!historydb_enabled)
have_filtered_listeners = has_filtered_listeners_now;
if (!have_filtered_listeners)
hlog(LOG_INFO, "Disabled historydb, listeners do not have filtering enabled.");
/* stop the dupechecking and uplink threads while adjusting

View File

@ -40,8 +40,6 @@ int dupecheck_running;
pthread_t dupecheck_th;
long dupecheck_cellgauge;
int historydb_enabled; /* historydb inserts enabled only if filtering available */
int pbuf_global_count;
int pbuf_global_dupe_count;
@ -656,7 +654,7 @@ static int dupecheck_drain_worker(struct worker_t *w,
* is enabled (disabled if no filtered listeners
* configured, for memory savings)
*/
if (historydb_enabled) {
if (have_filtered_listeners) {
historydb_insert(pb);
filter_postprocess_dupefilter(pb);
}

View File

@ -41,7 +41,6 @@ extern long long dupecheck_dupecount; /* statistics counter */
extern long long dupecheck_dupetypes[DTYPE_MAX+1];
extern long dupecheck_cellgauge; /* statistics gauge */
extern int historydb_enabled;
extern int dupecheck_eventfd;
extern int outgoing_lag_report(struct worker_t *self, int*lag, int*dupelag);

View File

@ -239,6 +239,7 @@ cellarena_t *filter_entrycall_cells;
cellarena_t *filter_wx_cells;
#endif
int have_filtered_listeners; /* do we have any filtered listeners, do we need to support them */
#define HIST_LOOKUP_INTERVAL 10 /* Cache historydb position lookups this much seconds on
each filter entry referring to some
@ -801,9 +802,12 @@ static void filter_keyhashes(struct pbuf_t *pb)
void filter_preprocess_dupefilter(struct pbuf_t *pbuf)
{
// TODO: could probably skip filter_check_tcpip, and possibly filter_keyhashes too if no filtered listeners
filter_check_tcpip(pbuf);
filter_entrycall_insert(pbuf);
filter_wx_insert(pbuf);
if (have_filtered_listeners) {
filter_entrycall_insert(pbuf);
filter_wx_insert(pbuf);
}
filter_keyhashes(pbuf);
}

View File

@ -35,6 +35,8 @@ extern void filter_wx_dump(FILE *fp);
extern int filter_cellgauge;
extern int have_filtered_listeners;
extern float filter_lat2rad(float lat);
extern float filter_lon2rad(float lon);