initscripts/new-network-fork-to-start-dhcp.patch
2020-07-24 11:24:21 +08:00

73 lines
2.3 KiB
Diff

From ad95c2dae06794a37e500e07e13cee8328ddfb5d Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Tue, 24 Sep 2019 17:39:52 +0800
Subject: [PATCH] initscripts: add network start dhcp process background
reason:add network start dhcp process background
Signed-off-by: rpm-build <rpm-build>
---
etc/rc.d/init.d/network | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/etc/rc.d/init.d/network b/etc/rc.d/init.d/network
index 31bbe20..994425d 100755
--- a/etc/rc.d/init.d/network
+++ b/etc/rc.d/init.d/network
@@ -49,6 +49,8 @@ interfaces=$(ls ifcfg-* | \
LC_ALL=C sed 's/ //')
rc=0
+godamon=0
+
net_log $"You are using 'network' service provided by 'network-scripts', which are now deprecated." warning network >&2
net_log $"'network-scripts' will be removed from distribution in near future." warning network >&2
net_log $"It is advised to switch to 'NetworkManager' instead for network management." warning network >&2
@@ -129,18 +131,39 @@ start)
is_available $i
continue
fi
- action $"Bringing up interface $i: " ./ifup $i boot
- [ $? -ne 0 ] && rc=1
+ if [ "$godamon" != "1" ] ; then
+ action $"Bringing up interface $i: " ./ifup $i boot
+ [ $? -ne 0 ] && rc=1
+ else
+ action $"Bringing up interface $i: " ./ifup $i boot &
+ fi
done
# Bring up xDSL and VPN interfaces
for i in $vlaninterfaces $bridgeinterfaces $xdslinterfaces $vpninterfaces ; do
if ( . ./ifcfg-"$i" ; ! is_false "$ONBOOT" ) ; then
- action $"Bringing up interface $i: " ./ifup $i boot
- [ $? -ne 0 ] && rc=1
+ if [ "$godamon" != "1" ] ; then
+ action $"Bringing up interface $i: " ./ifup $i boot
+ [ $? -ne 0 ] && rc=1
+ else
+ action $"Bringing up interface $i: " ./ifup $i boot &
+ fi
fi
done
-
+ # Waiting until all background process done
+ if [ "$godamon" = "1" ] ; then
+ for pid in $(jobs -p)
+ do
+ wait $pid
+ status=$?
+ if [ $status != 0 ] ;then
+ net_log "Unable to obtain DHCP addresas."
+ rc=1
+ continue
+ fi
+ rc=0
+ done
+ fi
# Add non interface-specific static-routes.
if [ -f /etc/sysconfig/static-routes ]; then
if [ -x /sbin/route ]; then
--
2.19.1