mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 11:01:09 +00:00
Rework resolv watcher
Handle symlinks better and do not trigger overly eagerly
This commit is contained in:
parent
754cdfdd78
commit
86891eb2e5
@ -502,8 +502,17 @@ class SockApi(object):
|
||||
def watch_resolv(self):
|
||||
while True:
|
||||
watcher = libc.inotify_init1(os.O_NONBLOCK)
|
||||
if libc.inotify_add_watch(watcher, b'/etc/resolv.conf', 0xcda) <= -1:
|
||||
break
|
||||
resolvpath = '/etc/resolv.conf'
|
||||
while True:
|
||||
try:
|
||||
resolvpath = os.readlink(resolvpath)
|
||||
except Exception:
|
||||
break
|
||||
if not isinstance(resolvpath, bytes):
|
||||
resolvpath = resolvpath.encode('utf8')
|
||||
if libc.inotify_add_watch(watcher, resolvpath, 0xcc2) <= -1:
|
||||
eventlet.sleep(15)
|
||||
continue
|
||||
select.select((watcher,), (), (), 86400)
|
||||
try:
|
||||
os.read(watcher, 1024)
|
||||
|
Loading…
Reference in New Issue
Block a user