service: Track online check for IPv4 and IPv6 separately
PATCH 1/2 service: Track online check for IPv4 and IPv6 separately
The online check is not distinguishing between IPv4 and IPv6 but the rest of the code assumes we handle them separately.
--- src/service.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
src/service.c +27 -12
@@ -137,7 +137,8 @@ struct connman_service {char *pac;bool wps;bool wps_advertizing; -guint online_timeout; +guint online_timeout_ipv4; +guint online_timeout_ipv6;unsigned int online_check_interval_ipv4;unsigned int online_check_interval_ipv6;bool do_split_routing;
@@ -1438,12 +1439,16 @@ static bool check_proxy_setup(struct connman_service *service)static void cancel_online_check (struct connman_service *service) { -if (service->online_timeout ==0 ) -return ; - -g_source_remove (service->online_timeout); - service->online_timeout =0 ; -connman_service_unref (service); +if (service->online_timeout_ipv4) { +g_source_remove (service->online_timeout_ipv4); + service->online_timeout_ipv4 =0 ; +connman_service_unref (service); + } +if (service->online_timeout_ipv6) { +g_source_remove (service->online_timeout_ipv6); + service->online_timeout_ipv6 =0 ; +connman_service_unref (service); + } } static void start_online_check(struct connman_service *service,
@@ -1461,7 +1466,7 @@ static void start_online_check(struct connman_service *service, online_check_max_interval =connman_setting_get_uint ("OnlineCheckMaxInterval" ); -if (type !=CONNMAN_IPCONFIG_TYPE_IPV4 ||check_proxy_setup (service)) { +if (type ==CONNMAN_IPCONFIG_TYPE_IPV6 ||check_proxy_setup (service)) {cancel_online_check (service);__connman_service_wispr_start (service, type); }
@@ -6330,20 +6335,20 @@ static void service_rp_filter(struct connman_service *service,static void redo_wispr (struct connman_service *service,enum connman_ipconfig_type type) { - service->online_timeout =0 ; -connman_service_unref (service); -DBG ("Retrying %s WISPr for %p %s" ,__connman_ipconfig_type2string (type), service, service->name);__connman_wispr_start (service, type); +connman_service_unref (service); }static gboolean redo_wispr_ipv4 (gpointer user_data) {struct connman_service *service = user_data; + service->online_timeout_ipv4 =0 ; +redo_wispr (service,CONNMAN_IPCONFIG_TYPE_IPV4 );return FALSE;
@@ -6353,6 +6358,8 @@ static gboolean redo_wispr_ipv6(gpointer user_data) {struct connman_service *service = user_data; + service->online_timeout_ipv6 =0 ; +redo_wispr (service,CONNMAN_IPCONFIG_TYPE_IPV6 );return FALSE;
@@ -6365,6 +6372,10 @@ void __connman_service_online_check(struct connman_service *service,GSourceFunc redo_func;unsigned int *interval;enum connman_service_state current_state; +int timeout; + +DBG ("service %p type %s success %d\n" , + service,__connman_ipconfig_type2string (type), success);if (type ==CONNMAN_IPCONFIG_TYPE_IPV4 ) { interval = &service->online_check_interval_ipv4;
@@ -6393,8 +6404,12 @@ void __connman_service_online_check(struct connman_service *service,DBG ("service %p type %s interval %d" , service,__connman_ipconfig_type2string (type), *interval); - service->online_timeout =g_timeout_add_seconds (*interval * *interval, + timeout =g_timeout_add_seconds (*interval * *interval, redo_func,connman_service_ref (service)); +if (type ==CONNMAN_IPCONFIG_TYPE_IPV4 ) + service->online_timeout_ipv4 = timeout; +else + service->online_timeout_ipv6 = timeout;/* Increment the interval for the next time, set a maximum timeout of * online_check_max_interval seconds * online_check_max_interval seconds.
Signature · 1 line
2.37.2
PATCH 2/2 wispr: Fix contex refcounting in wispr_portal_request_portal()
The wispr_portal_request_portal() function is expected to read until there is no data. Hence, the wp_context refcount is supposed to be hold on while reading.
Furthermore, we should not return early when we read the X-ConnMan-Status header. Instead we are supposed to go through the normal return path so that we cleanup any added routing entries. Thus, we also don't need to update the refcount in this code path as we handle it at the main return path.
While at it also do some cleanups and unify the connman_ipconfig_type checking.
--- src/wispr.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
src/wispr.c +6 -10
@@ -537,7 +537,8 @@ static bool wispr_route_request(const char *address, int ai_family,static void wispr_portal_request_portal (struct connman_wispr_portal_context *wp_context) { -DBG ("" ); +DBG ("wp_context %p %s" , wp_context, +__connman_ipconfig_type2string (wp_context->type));wispr_portal_context_ref (wp_context); wp_context->request_id = g_web_request_get(wp_context->web,
@@ -753,7 +754,7 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)if (length >0 ) {g_web_parser_feed_data (wp_context->wispr_parser, chunk, length); -wispr_portal_context_unref (wp_context); +/* read more data */ return true; }
@@ -783,8 +784,6 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)if (g_web_result_get_header (result,"X-ConnMan-Status" , &str)) {portal_manage_status (result, wp_context); -wispr_portal_context_unref (wp_context); -return false; }else {wispr_portal_context_ref (wp_context); __connman_agent_request_browser(wp_context->service,
@@ -996,7 +995,8 @@ int __connman_wispr_start(struct connman_service *service,struct connman_wispr_portal *wispr_portal =NULL ;int index, err; -DBG ("service %p" , service); +DBG ("service %p %s" , service, +__connman_ipconfig_type2string (type));if (!wispr_portal_hash)return -EINVAL ;
@@ -1033,12 +1033,8 @@ int __connman_wispr_start(struct connman_service *service,if (type ==CONNMAN_IPCONFIG_TYPE_IPV4 ) wp_context = wispr_portal->ipv4_context; -else if (type ==CONNMAN_IPCONFIG_TYPE_IPV6 ) +else wp_context = wispr_portal->ipv6_context; -else { - err = -EINVAL ; - goto free_wp; - }/* If there is already an existing context, we wipe it */ if (wp_context)
Signature · 1 line
2.37.2