From 1780bb28cfc7198483f0bd36aa0a90020698e2ba Mon Sep 17 00:00:00 2001 From: Alok Barsode Date: Wed, 24 Aug 2011 16:44:11 +0300 Subject: [PATCH] technology: Remove global rfkill table Remove the global rfkill_table and maintain a per technology rfkill table. --- src/connman.h | 4 +++- src/rfkill.c | 9 +++++---- src/technology.c | 16 +++++----------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/connman.h b/src/connman.h index 0a44805..08e1fed 100644 --- a/src/connman.h +++ b/src/connman.h @@ -324,9 +324,11 @@ int __connman_technology_add_rfkill(unsigned int index, connman_bool_t softblock, connman_bool_t hardblock); int __connman_technology_update_rfkill(unsigned int index, + enum connman_service_type type, connman_bool_t softblock, connman_bool_t hardblock); -int __connman_technology_remove_rfkill(unsigned int index); +int __connman_technology_remove_rfkill(unsigned int index, + enum connman_service_type type); void __connman_technology_add_interface(enum connman_service_type type, int index, const char *name, const char *ident); diff --git a/src/rfkill.c b/src/rfkill.c index 2a4458b..3d214ef 100644 --- a/src/rfkill.c +++ b/src/rfkill.c @@ -99,18 +99,19 @@ static GIOStatus rfkill_process(GIOChannel *chan) event->type, event->op, event->soft, event->hard); + type = convert_type(event->type); + switch (event->op) { case RFKILL_OP_ADD: - type = convert_type(event->type); __connman_technology_add_rfkill(event->idx, type, event->soft, event->hard); break; case RFKILL_OP_DEL: - __connman_technology_remove_rfkill(event->idx); + __connman_technology_remove_rfkill(event->idx, type); break; case RFKILL_OP_CHANGE: - __connman_technology_update_rfkill(event->idx, event->soft, - event->hard); + __connman_technology_update_rfkill(event->idx, type, + event->soft, event->hard); break; default: break; diff --git a/src/technology.c b/src/technology.c index cc44658..849d72a 100644 --- a/src/technology.c +++ b/src/technology.c @@ -32,7 +32,6 @@ static DBusConnection *connection; -static GHashTable *rfkill_table; static GHashTable *device_table; static GSList *technology_list = NULL; @@ -908,8 +907,6 @@ int __connman_technology_add_rfkill(unsigned int index, rfkill->softblock = softblock; rfkill->hardblock = hardblock; - g_hash_table_replace(rfkill_table, &rfkill->index, technology); - g_hash_table_replace(technology->rfkill_list, &rfkill->index, rfkill); blocked = (softblock || hardblock) ? TRUE : FALSE; @@ -927,6 +924,7 @@ int __connman_technology_add_rfkill(unsigned int index, } int __connman_technology_update_rfkill(unsigned int index, + enum connman_service_type type, connman_bool_t softblock, connman_bool_t hardblock) { @@ -936,7 +934,7 @@ int __connman_technology_update_rfkill(unsigned int index, DBG("index %u soft %u hard %u", index, softblock, hardblock); - technology = g_hash_table_lookup(rfkill_table, &index); + technology = technology_find(type); if (technology == NULL) return -ENXIO; @@ -976,7 +974,8 @@ int __connman_technology_update_rfkill(unsigned int index, return 0; } -int __connman_technology_remove_rfkill(unsigned int index) +int __connman_technology_remove_rfkill(unsigned int index, + enum connman_service_type type) { struct connman_technology *technology; struct connman_rfkill *rfkill; @@ -984,7 +983,7 @@ int __connman_technology_remove_rfkill(unsigned int index) DBG("index %u", index); - technology = g_hash_table_lookup(rfkill_table, &index); + technology = technology_find(type); if (technology == NULL) return -ENXIO; @@ -996,8 +995,6 @@ int __connman_technology_remove_rfkill(unsigned int index) g_hash_table_remove(technology->rfkill_list, &index); - g_hash_table_remove(rfkill_table, &index); - if (blocked && g_atomic_int_dec_and_test(&technology->blocked) == TRUE) { technology_blocked(technology, FALSE); @@ -1028,8 +1025,6 @@ int __connman_technology_init(void) connection = connman_dbus_get_connection(); - rfkill_table = g_hash_table_new_full(g_int_hash, g_int_equal, - NULL, unregister_technology); device_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, unregister_technology); @@ -1041,7 +1036,6 @@ void __connman_technology_cleanup(void) DBG(""); g_hash_table_destroy(device_table); - g_hash_table_destroy(rfkill_table); dbus_connection_unref(connection); } -- 2.7.4