diff options
-rw-r--r-- | src/connman.h | 2 | ||||
-rw-r--r-- | src/profile.c | 20 | ||||
-rw-r--r-- | src/service.c | 30 |
3 files changed, 30 insertions, 22 deletions
diff --git a/src/connman.h b/src/connman.h index 0ac1c713..b3aa487f 100644 --- a/src/connman.h +++ b/src/connman.h @@ -254,9 +254,11 @@ void __connman_service_put(struct connman_service *service); struct connman_service *__connman_service_lookup_from_device(struct connman_device *device); struct connman_service *__connman_service_create_from_device(struct connman_device *device); +void __connman_service_remove_from_device(struct connman_device *device); struct connman_service *__connman_service_lookup_from_network(struct connman_network *network); struct connman_service *__connman_service_create_from_network(struct connman_network *network); +void __connman_service_remove_from_network(struct connman_network *network); unsigned int __connman_service_get_order(struct connman_service *service); diff --git a/src/profile.c b/src/profile.c index 1fd3068d..ca316ed2 100644 --- a/src/profile.c +++ b/src/profile.c @@ -133,17 +133,9 @@ int __connman_profile_add_device(struct connman_device *device) int __connman_profile_remove_device(struct connman_device *device) { - struct connman_service *service; - DBG("device %p", device); - service = __connman_service_lookup_from_device(device); - if (service == NULL) - return -EINVAL; - - __connman_service_disconnect(service); - - __connman_service_put(service); + __connman_service_remove_from_device(device); return 0; } @@ -163,17 +155,9 @@ int __connman_profile_add_network(struct connman_network *network) int __connman_profile_remove_network(struct connman_network *network) { - struct connman_service *service; - DBG("network %p", network); - service = __connman_service_lookup_from_network(network); - if (service == NULL) - return -EINVAL; - - __connman_service_disconnect(service); - - __connman_service_put(service); + __connman_service_remove_from_network(network); return 0; } diff --git a/src/service.c b/src/service.c index 1da6aa3c..014ec9ec 100644 --- a/src/service.c +++ b/src/service.c @@ -814,11 +814,11 @@ void __connman_service_put(struct connman_service *service) reply_pending(service, EIO); + __connman_service_disconnect(service); + if (service->network != NULL) { connman_network_unref(service->network); service->network = NULL; - - interval = 5; } service->state = CONNMAN_SERVICE_STATE_FAILURE; @@ -1512,6 +1512,17 @@ done: return service; } +void __connman_service_remove_from_device(struct connman_device *device) +{ + struct connman_service *service; + + service = __connman_service_lookup_from_device(device); + if (service == NULL) + return; + + __connman_service_put(service); +} + /** * __connman_service_lookup_from_network: * @network: network structure @@ -1683,11 +1694,11 @@ struct connman_service *__connman_service_create_from_network(struct connman_net service->timeout = 0; } - connman_service_ref(service); - set_idle(service); } + connman_service_ref(service); + update_from_network(service, network); return service; } @@ -1737,6 +1748,17 @@ done: return service; } +void __connman_service_remove_from_network(struct connman_network *network) +{ + struct connman_service *service; + + service = __connman_service_lookup_from_network(network); + if (service == NULL) + return; + + __connman_service_put(service); +} + static int service_load(struct connman_service *service) { GKeyFile *keyfile; |