From 6db5525fbbf614003d99f8899e8dd2593ee7be22 Mon Sep 17 00:00:00 2001
From: Our Air Quality <info@ourairquality.org>
Date: Mon, 30 Apr 2018 14:06:08 +1000
Subject: [PATCH] sdk_wifi_station_dhcpc_stop: ensure the client is flagged as
 stopped.

Need to flag the dhcp client as stopped, even if the netif is not yet
initialized, because the flag is used to control the starting of the
dhcpc.
---
 open_esplibs/libmain/user_interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/open_esplibs/libmain/user_interface.c b/open_esplibs/libmain/user_interface.c
index 4483e5d..e81f175 100644
--- a/open_esplibs/libmain/user_interface.c
+++ b/open_esplibs/libmain/user_interface.c
@@ -563,12 +563,12 @@ bool sdk_wifi_station_dhcpc_stop(void) {
     if (sdk_wifi_get_opmode() == 2) {
         return false;
     }
+    LOCK_TCPIP_CORE();
     if (netif && sdk_dhcpc_flag == DHCP_STARTED) {
-        LOCK_TCPIP_CORE();
         dhcp_stop(netif);
-        sdk_dhcpc_flag = DHCP_STOPPED;
-        UNLOCK_TCPIP_CORE();
     }
+    sdk_dhcpc_flag = DHCP_STOPPED;
+    UNLOCK_TCPIP_CORE();
     return true;
 }