[PATCH v2] network:Keep network->connecting true during wifi association

yaming.chen <[email protected]> Tue, 20 Jan 2026 19:33:24 +0800
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
In the case of AutoConnect enabled, if the AP powers off, during
the first auto reconnection process, network->connecting is set
to false too early, resulting in no actual network disconnect
operation being performed in the __connman_network_disconnect
function, and the network info of GSupplicantInterface object is
not freed.

So when the AP powers on and connman triggers wifi auto
reconnection again, GSupplicantInterface object still returns
-EALREADY and network->connecting remains false.

If the task of autoscan_timeout and the associating event received
by connman from wpa_supplicant happen at the same time (Now auto
reconnection is dependent on wpa_supplicant), it will cause the
network object to be set as unavailable due to the function
__connman_technology_scan_started and freed in the stop_autoscan
function due to false network->connecting. Therefore, connman will
not do dhcp request after receiving the 4-way handshake and
completed events, and cannot allocate IP to STA device.

No matter how many times connman will request to reconnect to the
same AP again in the future, because the wifi state of wpa_supplicant
is already connected and the GSupplicantInterface object still
returns -EALREADY for connect request, STA will never actually do
the connect action again and will never be allocated an IP address
except for restarting wpa_supplicant forcibly.

---
Changes since v1:
- Format line indentation of the code

---
 src/network.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/network.c b/src/network.c
index 416a7e74..d3876efe 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1806,7 +1806,8 @@ int __connman_network_connect(struct connman_network *network)
 	if (err < 0) {
 		if (err == -EINPROGRESS)
 			connman_network_set_associating(network, true);
-		else
+		else if (err != -EALREADY ||
+				network->type != CONNMAN_NETWORK_TYPE_WIFI)
 			network->connecting = false;
 
 		return err;
-- 
2.34.1