From: Alok Barsode <[email protected]>
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 4d168b1..b04a262 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -322,9 +322,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 8865483..6c48af2 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;
@@ -943,8 +942,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;
@@ -962,6 +959,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)
{
@@ -971,7 +969,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;
@@ -1011,7 +1009,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;
@@ -1019,7 +1018,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;
@@ -1031,8 +1030,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);
@@ -1063,8 +1060,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);
@@ -1076,7 +1071,6 @@ void __connman_technology_cleanup(void)
DBG("");
g_hash_table_destroy(device_table);
- g_hash_table_destroy(rfkill_table);
dbus_connection_unref(connection);
}
--
1.7.1
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman