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).
This commit is contained in:
Richard Röjfors 2019-08-06 08:33:56 +00:00 committed by Denis Kenzior
parent cfac75a332
commit d4ced627e0
1 changed files with 21 additions and 2 deletions

View File

@ -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);