[PATCH 3/4] Add proxy cancel support.

Mohamed Abbas mabbas at linux.intel.com
Thu Jan 6 23:46:58 PST 2011


Make sure we cancel proxy request if we got disconnected and still
waiting for proxy request.
---
 plugins/portal.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/plugins/portal.c b/plugins/portal.c
index 043caaf..4e3dc51 100644
--- a/plugins/portal.c
+++ b/plugins/portal.c
@@ -39,6 +39,7 @@
 #define STATUS_URL  "http://www.connman.net/online/status.html"
 
 struct server_data {
+	unsigned int token;
 	GWeb *web;
 	guint request_id;
 };
@@ -105,18 +106,18 @@ static void proxy_callback(const char *proxy, void *user_data)
 		proxy = getenv("http_proxy");
 
 	if (data != NULL) {
-		g_web_set_proxy(data->web, proxy);
+		if (proxy != NULL && g_strcmp0(proxy, "DIRECT") != 0)
+			g_web_set_proxy(data->web, proxy);
 
 		data->request_id = g_web_request_get(data->web, STATUS_URL,
 							web_result, location);
 	}
-
-	connman_location_unref(location);
 }
 
 static int location_detect(struct connman_location *location)
 {
 	struct server_data *data;
+	struct connman_service *service;
 	enum connman_service_type service_type;
 	char *interface;
 	int err;
@@ -168,12 +169,12 @@ static int location_detect(struct connman_location *location)
 	g_web_set_user_agent(data->web, "ConnMan/%s", VERSION);
 	g_web_set_close_connection(data->web, TRUE);
 
-	err = connman_proxy_lookup(interface, STATUS_URL,
+	service = connman_location_get_service(location);
+	err = connman_proxy_lookup(interface, STATUS_URL, service,
 					proxy_callback, location);
 	if (err < 0)
 		goto done;
 
-	connman_location_ref(location);
 	err = 0;
 
 done:
@@ -192,6 +193,9 @@ static int location_finish(struct connman_location *location)
 	if (data->request_id > 0)
 		g_web_cancel_request(data->web, data->request_id);
 
+	if (data->token > 0)
+		connman_proxy_lookup_cancel(data->token);
+
 	g_web_unref(data->web);
 
 	g_free(data);
-- 
1.7.3.4




More information about the connman mailing list