summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/net/java/android/net/ip/IpServer.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/services/net/java/android/net/ip/IpServer.java b/services/net/java/android/net/ip/IpServer.java
index 66884c60b0bc..6a6a1307723e 100644
--- a/services/net/java/android/net/ip/IpServer.java
+++ b/services/net/java/android/net/ip/IpServer.java
@@ -433,6 +433,9 @@ public class IpServer extends StateMachine {
}
}
ifcg.clearFlag("running");
+
+ // TODO: this may throw if the interface is already gone. Do proper handling and
+ // simplify the DHCP server start/stop.
mNMService.setInterfaceConfig(mIfaceName, ifcg);
if (!configureDhcp(enabled, (Inet4Address) addr, prefixLen)) {
@@ -440,6 +443,14 @@ public class IpServer extends StateMachine {
}
} catch (Exception e) {
mLog.e("Error configuring interface " + e);
+ if (!enabled) {
+ try {
+ // Calling stopDhcp several times is fine
+ stopDhcp();
+ } catch (Exception dhcpError) {
+ mLog.e("Error stopping DHCP", dhcpError);
+ }
+ }
return false;
}