From 289bd14bbf652aeea3c4c89ebfa9bf705c3c71c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 1 Apr 2022 23:48:06 +0200 Subject: [PATCH] Do not start status report on platform without AF_UNIX socket issue11319 review393871002 (grafted from f9c934230c6b1f7d8c5ee4a3722227ced19393ae) --HG-- branch : 6.0 --- bin/trytond-stat | 5 +++-- trytond/status.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/trytond-stat b/bin/trytond-stat index 1605d6b9e2..bc1a48772c 100755 --- a/bin/trytond-stat +++ b/bin/trytond-stat @@ -125,7 +125,8 @@ def main(stdscr): processes[pid] = data refresh() refresh() - status.listen(config.get('database', 'path'), update) + return status.listen(config.get('database', 'path'), update) -curses.wrapper(main) +if not curses.wrapper(main): + sys.stderr.write("status not supported on this platform\n") diff --git a/trytond/status.py b/trytond/status.py index 36e3533e4f..842d82f58d 100644 --- a/trytond/status.py +++ b/trytond/status.py @@ -48,6 +48,8 @@ def log(): def dump(path): + if not hasattr(socket, 'AF_UNIX'): + return False sock = socket.socket(socket.AF_UNIX) try: try: @@ -73,6 +75,8 @@ def dumper(path): def start(path): global _PID, _PATH + if not hasattr(socket, 'AF_UNIX'): + return if _PID != os.getpid() and path: # Quick test without lock with _LOCK: if _PID != os.getpid(): @@ -83,6 +87,8 @@ def start(path): def listen(path, callback=None): + if not hasattr(socket, 'AF_UNIX'): + return False sock = socket.socket(socket.AF_UNIX) socket_file = os.path.join(path, address) try: @@ -115,3 +121,4 @@ def listen(path, callback=None): finally: sock.close() os.unlink(socket_file) + return True