mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
Unbound: small optimizations
No need to register callbacks when stats are not enabled and no need to use a circular buffer on the logger side since we don't need to append left. This avoids the need for converting it to a list.
This commit is contained in:
parent
fa72225d8d
commit
3170c77880
@ -36,7 +36,6 @@ import pandas
|
||||
import signal
|
||||
import socket
|
||||
import duckdb
|
||||
from collections import deque
|
||||
sys.path.insert(0, "/usr/local/opnsense/site-python")
|
||||
from duckdb_helper import DbConnection
|
||||
|
||||
@ -46,7 +45,7 @@ class DNSReader:
|
||||
self.timer = 0
|
||||
self.cleanup_timer = 0
|
||||
self.flush_interval = flush_interval
|
||||
self.buffer = deque()
|
||||
self.buffer = list()
|
||||
self.selector = selectors.DefaultSelector()
|
||||
self.fd = None
|
||||
|
||||
@ -165,7 +164,7 @@ class DNSReader:
|
||||
if len(self.buffer) > 0:
|
||||
# construct a dataframe from the current buffer and empty it. This is orders of magniture
|
||||
# faster than transactional inserts, and doesn't block even under high load.
|
||||
db.connection.append('query', pandas.DataFrame(list(self.buffer)))
|
||||
db.connection.append('query', pandas.DataFrame(self.buffer))
|
||||
self.buffer.clear()
|
||||
for client in self.update_clients:
|
||||
# attempt to resolve every client IP we've seen in between intervals (if necessary)
|
||||
|
||||
@ -249,14 +249,15 @@ def init_standard(id, env):
|
||||
ctx = ModuleContext(env)
|
||||
mod_env['context'] = ctx
|
||||
|
||||
if not register_inplace_cb_reply_cache(cache_cb, env, id):
|
||||
return False
|
||||
if ctx.stats_enabled:
|
||||
if not register_inplace_cb_reply_cache(cache_cb, env, id):
|
||||
return False
|
||||
|
||||
if not register_inplace_cb_reply_local(local_cb, env, id):
|
||||
return False
|
||||
if not register_inplace_cb_reply_local(local_cb, env, id):
|
||||
return False
|
||||
|
||||
if not register_inplace_cb_reply_servfail(servfail_cb, env, id):
|
||||
return False
|
||||
if not register_inplace_cb_reply_servfail(servfail_cb, env, id):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@ -285,8 +286,8 @@ def operate(id, event, qstate, qdata):
|
||||
|
||||
if event == MODULE_EVENT_MODDONE:
|
||||
# Iterator finished, show response (if any)
|
||||
if 'query' in qdata and 'start_time' in qdata:
|
||||
ctx = mod_env['context']
|
||||
ctx = mod_env['context']
|
||||
if ctx.stats_enabled and 'query' in qdata and 'start_time' in qdata:
|
||||
dnssec = sec_status_unchecked
|
||||
rcode = RCODE_SERVFAIL
|
||||
ttl = 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user