提交 7cfc223c 编写于 作者: A Alessio Sergi

Working around netifaces segfault on FreeBSD

netifaces.gateways() function segmentation fault on FreeBSD, making
Glances unusable. As a workaround, just disable netifaces on FreeBSD.
See https://bitbucket.org/al45tair/netifaces/issues/15.

Fixes #670.
上级 1427274e
......@@ -35,7 +35,7 @@ except ImportError:
zeroconf_tag = False
# Import Glances libs
from glances.core.glances_globals import appname
from glances.core.glances_globals import appname, is_freebsd
from glances.core.glances_logging import logger
# Zeroconf 0.17 or higher is needed
......@@ -194,13 +194,16 @@ class GlancesAutoDiscoverClient(object):
except socket.error as e:
logger.error("Cannot start zeroconf: {0}".format(e))
try:
# -B @ overwrite the dynamic IPv4 choice
if zeroconf_bind_address == '0.0.0.0':
zeroconf_bind_address = self.find_active_ip_address()
except KeyError:
# Issue #528 (no network interface available)
pass
# XXX FreeBSD: Segmentation fault (core dumped)
# -- https://bitbucket.org/al45tair/netifaces/issues/15
if not is_freebsd:
try:
# -B @ overwrite the dynamic IPv4 choice
if zeroconf_bind_address == '0.0.0.0':
zeroconf_bind_address = self.find_active_ip_address()
except KeyError:
# Issue #528 (no network interface available)
pass
print("Announce the Glances server on the LAN (using {0} IP address)".format(zeroconf_bind_address))
self.info = ServiceInfo(
......
......@@ -33,6 +33,7 @@ is_py3 = sys.version_info >= (3, 3)
# Operating system flag
# Note: Somes libs depends of OS
is_bsd = sys.platform.find('bsd') != -1
is_freebsd = sys.platform.startswith('freebsd')
is_linux = sys.platform.startswith('linux')
is_mac = sys.platform.startswith('darwin')
is_windows = sys.platform.startswith('win')
......
......@@ -19,17 +19,22 @@
"""IP plugin."""
# Import system libs
try:
import netifaces
netifaces_tag = True
except ImportError:
netifaces_tag = False
# Import Glances libs
from glances.core.glances_globals import is_freebsd
from glances.core.glances_logging import logger
from glances.plugins.glances_plugin import GlancesPlugin
# XXX FreeBSD: Segmentation fault (core dumped)
# -- https://bitbucket.org/al45tair/netifaces/issues/15
if not is_freebsd:
try:
import netifaces
netifaces_tag = True
except ImportError:
netifaces_tag = False
else:
netifaces_tag = False
class Plugin(GlancesPlugin):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册