summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-07-15 09:54:43 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-07-15 09:54:43 +0200
commit16200f1b1c0fc2eadd5c16703924a1345b3dfdb5 (patch)
tree180832823c4ddcefc9ab0d8597ea8e966160430e
parente08a0998784d96326ce4f632b094ab017cb9bd7e (diff)
downloadconnman-16200f1b1c0fc2eadd5c16703924a1345b3dfdb5.tar.gz
connman-16200f1b1c0fc2eadd5c16703924a1345b3dfdb5.tar.bz2
connman-16200f1b1c0fc2eadd5c16703924a1345b3dfdb5.zip
Return a proper order value for the default service
-rw-r--r--src/connection.c12
-rw-r--r--src/service.c11
2 files changed, 18 insertions, 5 deletions
diff --git a/src/connection.c b/src/connection.c
index b20a5a19..ac6c2e5e 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -243,8 +243,7 @@ static struct gateway_data *add_gateway(int index, const char *gateway)
find_element, data);
service = __connman_element_get_service(data->element);
- if (service != NULL)
- data->order = __connman_service_get_order(service);
+ data->order = __connman_service_get_order(service);
gateway_list = g_slist_append(gateway_list, data);
@@ -281,12 +280,16 @@ static void set_default_gateway(struct gateway_data *data)
static struct gateway_data *find_default_gateway(void)
{
struct gateway_data *found = NULL;
+ unsigned int order = 0;
GSList *list;
for (list = gateway_list; list; list = list->next) {
struct gateway_data *data = list->data;
- /* just return the last one for now */
- found = data;
+
+ if (found == NULL || data->order > order) {
+ found = data;
+ order = data->order;
+ }
}
return found;
@@ -640,7 +643,6 @@ static void update_order(void)
struct connman_service *service;
service = __connman_element_get_service(data->element);
-
data->order = __connman_service_get_order(service);
}
}
diff --git a/src/service.c b/src/service.c
index 786efd72..79e4cb0f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1333,9 +1333,20 @@ struct connman_service *__connman_service_lookup_from_network(struct connman_net
unsigned int __connman_service_get_order(struct connman_service *service)
{
+ GSequenceIter *iter;
+
if (service == NULL)
return 0;
+ if (service->favorite == FALSE)
+ return 0;
+
+ iter = g_hash_table_lookup(service_hash, service->identifier);
+ if (iter != NULL) {
+ if (g_sequence_iter_get_position(iter) == 0)
+ return 1;
+ }
+
return service->order;
}