summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Röjfors <richard@puffinpack.se>2019-08-06 08:33:56 +0000
committerDenis Kenzior <denkenz@gmail.com>2019-08-07 16:54:25 -0500
commitd4ced627e068e73a570da5d9e8ee451595c79c23 (patch)
treee007a7582b10e5b54c707b733888e0bd01bac3f1 /src
parentcfac75a332836295a90a48ace7c99598c5d9d6a1 (diff)
downloadofono-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')
-rw-r--r--src/gprs.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gprs.c b/src/gprs.c
index bdb8c8a2..d554dab1 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -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);