[PATCH v2 37/42] vpn-provider: Delay connect of daemonless VPNs until connmand is online

Jussi Laakkonen <[email protected]> Wed, 13 Aug 2025 18:02:09 +0300
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
When the connmand state has been queried and a daemonless VPN is being
connected it must be connected later when online state is reached. This
ensures that if the online check on connmand transport is slow, the
daemonless VPN will get connected when state changes.
---
 vpn/vpn-provider.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index b81e3df4..966866b9 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -920,6 +920,15 @@ static DBusMessage *do_connect(DBusConnection *conn, DBusMessage *msg,
 
 	if (!is_connman_connected(provider)) {
 		if (state_query_completed) {
+			/* Query done but connmand not online for daemonless */
+			if (connman_online_state >= CONNMAN_READY) {
+				DBG("Provider %s start delayed, wait for "
+						"connman online state",
+						provider->identifier);
+				do_connect_later(provider, conn, msg);
+				return NULL;
+			}
+
 			DBG("%s not started - ConnMan not online/ready",
 				provider->identifier);
 			return __connman_error_failed(msg, ENOLINK);
-- 
2.39.5