unbound: wait for a pipe a bit (#6331)

This commit is contained in:
kulikov-a 2023-02-16 17:13:05 +03:00 committed by GitHub
parent 8cb5ec0e38
commit 7ebe361340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -185,14 +185,22 @@ class DNSReader:
self._setup_db()
try:
# open() will block until a query has been pushed down the fifo
self.fd = open(self.target_pipe, 'r')
except InterruptedError:
self.close_logger()
except OSError:
syslog.syslog(syslog.LOG_ERR, "Unable to open pipe. This is likely because Unbound isn't running.")
sys.exit(1)
r_count = 0
pipe_ready = False
# give dnsbl_module.py some time to create a pipe
while r_count < 3 and not pipe_ready:
try:
# open() will block until a query has been pushed down the fifo
self.fd = open(self.target_pipe, 'r')
pipe_ready = True
except InterruptedError:
self.close_logger()
except OSError:
r_count =+ 1
if r_count == 3:
syslog.syslog(syslog.LOG_ERR, "Unable to open pipe. This is likely because Unbound isn't running.")
sys.exit(1)
time.sleep(1)
self.selector.register(self.fd.fileno(), selectors.EVENT_READ, self._read)