diff options
author | Richard Röjfors <richard@puffinpack.se> | 2019-08-06 08:33:56 +0000 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2019-08-07 16:54:25 -0500 |
commit | d4ced627e068e73a570da5d9e8ee451595c79c23 (patch) | |
tree | e007a7582b10e5b54c707b733888e0bd01bac3f1 /src/gprs.c | |
parent | cfac75a332836295a90a48ace7c99598c5d9d6a1 (diff) | |
download | ofono-d4ced627e068e73a570da5d9e8ee451595c79c23.tar.gz |
gprs: Use -1 as netreg status during init.
Previously the valid "unknown" netreg status was set
during startup, but its a bit problematic for gprs.
There might be cases where a LTE context is activated
before netreg is finished updating its status.
Resulting in gprs taking faulty actions.
Instead we set the status to -1 until we are updated
with a known value.
During the time the status is -1, gprs postpones actions until
the status is valid (>= 0).
Diffstat (limited to 'src/gprs.c')
-rw-r--r-- | src/gprs.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -1661,6 +1661,15 @@ static void gprs_netreg_update(struct ofono_gprs *gprs) { ofono_bool_t attach; + /* + * This function can get called by other reasons than netreg + * updating its status. So check if we have a valid netreg status yet. + * The only reason for not having a valid status is basically during + * startup while the netreg atom is fetching the status. + */ + if (gprs->netreg_status < 0) + return; + attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED; attach = attach || (gprs->roaming_allowed && @@ -3084,7 +3093,7 @@ struct ofono_gprs *ofono_gprs_create(struct ofono_modem *modem, } gprs->status = NETWORK_REGISTRATION_STATUS_UNKNOWN; - gprs->netreg_status = NETWORK_REGISTRATION_STATUS_UNKNOWN; + gprs->netreg_status = -1; gprs->used_pids = l_uintset_new(MAX_CONTEXTS); return gprs; @@ -3095,6 +3104,7 @@ static void netreg_watch(struct ofono_atom *atom, void *data) { struct ofono_gprs *gprs = data; + int status; if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) { gprs_netreg_removed(gprs); @@ -3102,7 +3112,16 @@ static void netreg_watch(struct ofono_atom *atom, } gprs->netreg = __ofono_atom_get_data(atom); - gprs->netreg_status = ofono_netreg_get_status(gprs->netreg); + status = ofono_netreg_get_status(gprs->netreg); + + /* + * If the status is known, assign it, otherwise keep the init value + * to indicate that the netreg atom is not initialised with a known + * value + */ + if (status != NETWORK_REGISTRATION_STATUS_UNKNOWN) + gprs->netreg_status = status; + gprs->status_watch = __ofono_netreg_add_status_watch(gprs->netreg, netreg_status_changed, gprs, NULL); |