Skip to content

Commit

Permalink
session: Do no create two instances of struct connman_service_info
Browse files Browse the repository at this point in the history
service_state_changed gets called for READY and ONLINE state. struct
connman_service_info *info needs only to be updated and not created on
the second call (transition from READY -> ONLINE).
  • Loading branch information
Daniel Wagner authored and pfl committed Mar 4, 2014
1 parent 76cb209 commit aae5825
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/session.c
Expand Up @@ -1605,14 +1605,15 @@ static void service_state_changed(struct connman_service *service,

DBG("service %p state %d", service, state);

info = g_hash_table_lookup(service_hash, service);

switch (state) {
case CONNMAN_SERVICE_STATE_UNKNOWN:
case CONNMAN_SERVICE_STATE_IDLE:
case CONNMAN_SERVICE_STATE_ASSOCIATION:
case CONNMAN_SERVICE_STATE_CONFIGURATION:
case CONNMAN_SERVICE_STATE_FAILURE:
case CONNMAN_SERVICE_STATE_DISCONNECT:
info = g_hash_table_lookup(service_hash, service);
if (!info)
return;

Expand All @@ -1623,12 +1624,13 @@ static void service_state_changed(struct connman_service *service,
return;
case CONNMAN_SERVICE_STATE_READY:
case CONNMAN_SERVICE_STATE_ONLINE:
info = g_new0(struct connman_service_info, 1);
if (!info) {
info = g_new0(struct connman_service_info, 1);
g_hash_table_replace(service_hash, service, info);
}

info->service = service;
handle_service_state_online(service, state, info);

g_hash_table_replace(service_hash, service, info);
}
}

Expand Down

0 comments on commit aae5825

Please sign in to comment.