From e52556affb42ce5e941e4cf48f45ed0100f10bfd Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 24 Aug 2020 14:00:47 -0400 Subject: [PATCH] Fix certificate watch hang If no certificate present, then once a day confluent could hang. Fix by doing a non-blocking read on the watcher. --- confluent_server/confluent/sockapi.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/sockapi.py b/confluent_server/confluent/sockapi.py index 61f5b49a..623b33f7 100644 --- a/confluent_server/confluent/sockapi.py +++ b/confluent_server/confluent/sockapi.py @@ -477,11 +477,14 @@ class SockApi(object): def watch_for_cert(self): libc = ctypes.CDLL(ctypes.util.find_library('c')) - watcher = libc.inotify_init() + watcher = libc.inotify_init1(os.O_NONBLOCK) if libc.inotify_add_watch(watcher, b'/etc/confluent/', 0x100) > -1: while True: select.select((watcher,), (), (), 86400) - os.read(watcher, 1024) + try: + os.read(watcher, 1024) + except Exception: + pass if self.should_run_remoteapi(): os.close(watcher) self.start_remoteapi()