diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2013-12-21 03:09:24 +0100 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2013-12-21 03:09:24 +0100 |
commit | 67cbacd2c1cc61fcc8a4cb8ca2d567bebec7a814 (patch) | |
tree | e901b523010b7c089e213e8d023a1a350bbd4c5f | |
parent | e2fed8e93c245b2fd1d4fd8059e25862c0abd47c (diff) | |
download | drakx-net-67cbacd2c1cc61fcc8a4cb8ca2d567bebec7a814.tar drakx-net-67cbacd2c1cc61fcc8a4cb8ca2d567bebec7a814.tar.gz drakx-net-67cbacd2c1cc61fcc8a4cb8ca2d567bebec7a814.tar.bz2 drakx-net-67cbacd2c1cc61fcc8a4cb8ca2d567bebec7a814.tar.xz drakx-net-67cbacd2c1cc61fcc8a4cb8ca2d567bebec7a814.zip |
prevent segfaulting b/c of fork vs threads (mga#12041)
the issue is that glib/gtk create threads behind us
however threads & fork() don't behave well when mixed...
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | lib/network/tools.pm | 14 |
2 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,6 @@ +- prevent segfaulting on forking when glib/gtk create threads behind us + (mga#12041) + 2.5 - fix mga web url (mga#11972) - do not request password for draknetcenter (mga#12017) diff --git a/lib/network/tools.pm b/lib/network/tools.pm index c80c269..c8e0cf6 100644 --- a/lib/network/tools.pm +++ b/lib/network/tools.pm @@ -216,8 +216,20 @@ sub get_default_connection { return $gw_intf, get_interface_status($gw_intf), $net->{resolv}{dnsServer}; } +#- returns the gateway address +# advantage over get_default_connection() is that we don't fork, +# which prevent segfaulting when glib/gtk create threads behind us (mga#12041) +sub get_gw_address() { + my $gateway; + foreach (cat_('/proc/net/route')) { + $gateway = $1 if /^\S+\s+00000000\s+([0-9A-F]+)/; + } + # Linux gives it as a hex number in network byte order: + $gateway ? join(".", unpack "CCCC", pack "L", hex $gateway) : undef; +} + sub has_network_connection() { - (undef, undef, my $gw_address) = get_default_connection({}); + my $gw_address = get_gw_address(); to_bool($gw_address); } |