aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2024-03-26 09:56:38 +0000
committerAleksander Morgado <aleksander@aleksander.es>2024-03-27 12:09:32 +0000
commit4ed45af376b511d5fecd43d24821b652e0ebc96b (patch)
tree491cbb22d078e9ef4b969b1ead72e64443235ef9 /src
parent4ef5ab6db7f506ef69388bf44acbf01c25b4c5d4 (diff)
broadband-modem: track primary/secondary ports while enabling/disabling 3GPP URCs
We should not blindly assume that peek_port_primary() always returns a valid port, because the device may have been ejected while the AT sequence is running. Instead, keep a valid port object reference in the operation context, and use it in all the AT command requests. The requests will fail if the device has been ejected, but the port object reference will be valid and the daemon won't crash.
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index d01aebbc..6f245957 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -5461,6 +5461,8 @@ modem_3gpp_create_initial_eps_bearer (MMIfaceModem3gpp *self,
/* Enable/Disable unsolicited registration events (3GPP interface) */
typedef struct {
+ MMPortSerialAt *primary;
+ MMPortSerialAt *secondary; /* optional */
gboolean enable; /* TRUE for enabling, FALSE for disabling */
gboolean run_cs;
gboolean run_ps;
@@ -5478,6 +5480,8 @@ typedef struct {
static void
unsolicited_registration_events_context_free (UnsolicitedRegistrationEventsContext *ctx)
{
+ g_clear_object (&ctx->primary);
+ g_clear_object (&ctx->secondary);
if (ctx->cs_error)
g_error_free (ctx->cs_error);
if (ctx->ps_error)
@@ -5504,6 +5508,8 @@ unsolicited_registration_events_task_new (MMBroadbandModem *self,
ctx->run_cs = cs_supported;
ctx->run_ps = ps_supported;
ctx->run_eps = eps_supported;
+ ctx->primary = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
+ ctx->secondary = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
task = g_task_new (self, NULL, callback, user_data);
g_task_set_task_data (task,
@@ -5595,7 +5601,6 @@ unsolicited_registration_events_sequence_ready (MMBroadbandModem *self,
UnsolicitedRegistrationEventsContext *ctx;
GError *error = NULL;
GVariant *command;
- MMPortSerialAt *secondary;
ctx = g_task_get_task_data (task);
@@ -5664,8 +5669,7 @@ unsolicited_registration_events_sequence_ready (MMBroadbandModem *self,
/* Even if primary failed, go on and try to enable in secondary port */
}
- secondary = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
- if (secondary) {
+ if (ctx->secondary) {
const MMBaseModemAtCommand *registration_sequence = NULL;
ctx->secondary_done = TRUE;
@@ -5674,7 +5678,7 @@ unsolicited_registration_events_sequence_ready (MMBroadbandModem *self,
if (command) {
mm_base_modem_at_command_full (
MM_BASE_MODEM (self),
- secondary,
+ ctx->secondary,
g_variant_get_string (command, NULL),
3,
FALSE,
@@ -5695,7 +5699,7 @@ unsolicited_registration_events_sequence_ready (MMBroadbandModem *self,
registration_sequence = ctx->enable ? eps_registration_sequence : eps_unregistration_sequence;
mm_base_modem_at_sequence_full (
MM_BASE_MODEM (self),
- secondary,
+ ctx->secondary,
registration_sequence,
NULL, /* response processor context */
NULL, /* response processor context free */
@@ -5729,7 +5733,7 @@ unsolicited_registration_events_context_step (GTask *task)
ctx->run_cs = FALSE;
mm_base_modem_at_sequence_full (
MM_BASE_MODEM (self),
- mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
+ ctx->primary,
ctx->enable ? cs_registration_sequence : cs_unregistration_sequence,
NULL, /* response processor context */
NULL, /* response processor context free */
@@ -5744,7 +5748,7 @@ unsolicited_registration_events_context_step (GTask *task)
ctx->run_ps = FALSE;
mm_base_modem_at_sequence_full (
MM_BASE_MODEM (self),
- mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
+ ctx->primary,
ctx->enable ? ps_registration_sequence : ps_unregistration_sequence,
NULL, /* response processor context */
NULL, /* response processor context free */
@@ -5759,7 +5763,7 @@ unsolicited_registration_events_context_step (GTask *task)
ctx->run_eps = FALSE;
mm_base_modem_at_sequence_full (
MM_BASE_MODEM (self),
- mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
+ ctx->primary,
ctx->enable ? eps_registration_sequence : eps_unregistration_sequence,
NULL, /* response processor context */
NULL, /* response processor context free */