mirror of git://git.sysmocom.de/ofono
gril: Fix access to notify callbacks
Entries to the table of notification callbacks can be added by the callbacks while being called. This caused a glib error as gril was using an iterator to the hash table while the table was being modified. Fixed by avoiding the unnecesary loop.
This commit is contained in:
parent
2113b0a5ed
commit
08834f9c2f
36
gril/gril.c
36
gril/gril.c
|
@ -420,48 +420,36 @@ static gboolean node_check_destroyed(struct ril_notify_node *node,
|
|||
|
||||
static void handle_unsol_req(struct ril_s *p, struct ril_msg *message)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
struct ril_notify *notify;
|
||||
int req_key;
|
||||
gpointer key, value;
|
||||
GList *list_item;
|
||||
struct ril_notify_node *node;
|
||||
gboolean found = FALSE;
|
||||
|
||||
if (p->notify_list == NULL)
|
||||
return;
|
||||
|
||||
p->in_notify = TRUE;
|
||||
|
||||
g_hash_table_iter_init(&iter, p->notify_list);
|
||||
notify = g_hash_table_lookup(p->notify_list, &message->req);
|
||||
if (notify != NULL) {
|
||||
GSList *list_item;
|
||||
|
||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||
req_key = *((int *)key);
|
||||
notify = value;
|
||||
for (list_item = notify->nodes; list_item;
|
||||
list_item = g_slist_next(list_item)) {
|
||||
struct ril_notify_node *node = list_item->data;
|
||||
|
||||
if (req_key != message->req)
|
||||
continue;
|
||||
|
||||
list_item = (GList *) notify->nodes;
|
||||
|
||||
while (list_item != NULL) {
|
||||
node = list_item->data;
|
||||
if (node->destroyed)
|
||||
continue;
|
||||
|
||||
node->callback(message, node->user_data);
|
||||
found = TRUE;
|
||||
list_item = (GList *) g_slist_next(list_item);
|
||||
}
|
||||
}
|
||||
|
||||
/* Only log events not being listended for... */
|
||||
if (!found)
|
||||
} else {
|
||||
/* Only log events not being listended for... */
|
||||
DBG("RIL Event slot %d: %s\n",
|
||||
p->slot, unsol_request_to_string(p, message->req));
|
||||
}
|
||||
|
||||
p->in_notify = FALSE;
|
||||
|
||||
/* Now destroy nodes possibly removed by callbacks */
|
||||
if (found)
|
||||
if (notify != NULL)
|
||||
ril_unregister_all(p, FALSE, node_check_destroyed,
|
||||
GUINT_TO_POINTER(TRUE));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue