aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2023-01-17 08:44:15 +0100
committerAleksander Morgado <aleksander@aleksander.es>2023-04-11 13:49:03 +0000
commit0c1ad4eb77fc435920edc07905f6340b976621e2 (patch)
tree4742b9cedc67ee49e4639e606ab6c0ef208b1a94
parentda55fa769ee98aa4ec731418086cbff264eb4401 (diff)
base-modem-at: use better names for pairs of dependent cancellables
We cancel AT commands (or sequences) on cancellation of the modem's cancellable as well as of the optional user-provided one. However, the GTask can be associated with only one. That's okay if the user didn't supply one -- we just use the modem's cancellable only. Otherwise we chain the cancellables together (also cancel the user one with the modem one) at cost of some extra complexity. This aims to make the above a little clearer by using hopefully better names. Suggested-by: Aleksander Morgado <aleksandermj@chromium.org>
-rw-r--r--src/mm-base-modem-at.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/mm-base-modem-at.c b/src/mm-base-modem-at.c
index f7bc6a59..ed354063 100644
--- a/src/mm-base-modem-at.c
+++ b/src/mm-base-modem-at.c
@@ -73,10 +73,10 @@ abort_task_if_port_unusable (MMBaseModem *self,
}
static void
-modem_cancellable_cancelled (GCancellable *modem_cancellable,
- GCancellable *user_cancellable)
+parent_cancellable_cancelled (GCancellable *parent_cancellable,
+ GCancellable *cancellable)
{
- g_cancellable_cancel (user_cancellable);
+ g_cancellable_cancel (cancellable);
}
/*****************************************************************************/
@@ -85,7 +85,7 @@ modem_cancellable_cancelled (GCancellable *modem_cancellable,
typedef struct {
MMPortSerialAt *port;
gulong cancelled_id;
- GCancellable *modem_cancellable;
+ GCancellable *parent_cancellable;
const MMBaseModemAtCommand *current;
const MMBaseModemAtCommand *sequence;
gpointer response_processor_context;
@@ -103,10 +103,10 @@ at_sequence_context_free (AtSequenceContext *ctx)
ctx->response_processor_context_free)
ctx->response_processor_context_free (ctx->response_processor_context);
- if (ctx->modem_cancellable) {
- g_cancellable_disconnect (ctx->modem_cancellable,
+ if (ctx->parent_cancellable) {
+ g_cancellable_disconnect (ctx->parent_cancellable,
ctx->cancelled_id);
- g_object_unref (ctx->modem_cancellable);
+ g_object_unref (ctx->parent_cancellable);
}
if (ctx->result)
@@ -233,7 +233,7 @@ at_sequence_common (MMBaseModem *self,
gpointer response_processor_context,
GDestroyNotify response_processor_context_free,
GTask *task,
- GCancellable *modem_cancellable)
+ GCancellable *parent_cancellable)
{
AtSequenceContext *ctx;
@@ -250,14 +250,14 @@ at_sequence_common (MMBaseModem *self,
/* Ensure the cancellable that's already associated with the modem
* will also get cancelled if the modem wide-one gets cancelled */
- if (modem_cancellable) {
- GCancellable *user_cancellable;
-
- user_cancellable = g_task_get_cancellable (task);
- ctx->modem_cancellable = g_object_ref (modem_cancellable);
- ctx->cancelled_id = g_cancellable_connect (ctx->modem_cancellable,
- G_CALLBACK (modem_cancellable_cancelled),
- user_cancellable,
+ if (parent_cancellable) {
+ GCancellable *cancellable;
+
+ cancellable = g_task_get_cancellable (task);
+ ctx->parent_cancellable = g_object_ref (parent_cancellable);
+ ctx->cancelled_id = g_cancellable_connect (ctx->parent_cancellable,
+ G_CALLBACK (parent_cancellable_cancelled),
+ cancellable,
NULL);
}
@@ -469,7 +469,7 @@ mm_base_modem_response_processor_string_ignore_at_errors (MMBaseModem *self,
typedef struct {
MMPortSerialAt *port;
gulong cancelled_id;
- GCancellable *modem_cancellable;
+ GCancellable *parent_cancellable;
gchar *response;
} AtCommandContext;
@@ -478,10 +478,10 @@ at_command_context_free (AtCommandContext *ctx)
{
mm_port_serial_close (MM_PORT_SERIAL (ctx->port));
- if (ctx->modem_cancellable) {
- g_cancellable_disconnect (ctx->modem_cancellable,
+ if (ctx->parent_cancellable) {
+ g_cancellable_disconnect (ctx->parent_cancellable,
ctx->cancelled_id);
- g_object_unref (ctx->modem_cancellable);
+ g_object_unref (ctx->parent_cancellable);
}
g_object_unref (ctx->port);
@@ -536,7 +536,7 @@ at_command_common (MMBaseModem *self,
gboolean allow_cached,
gboolean is_raw,
GTask *task,
- GCancellable *modem_cancellable)
+ GCancellable *parent_cancellable)
{
AtCommandContext *ctx;
@@ -549,14 +549,14 @@ at_command_common (MMBaseModem *self,
/* Ensure the cancellable that's already associated with the modem
* will also get cancelled if the modem wide-one gets cancelled */
- if (modem_cancellable) {
- GCancellable *user_cancellable;
-
- user_cancellable = g_task_get_cancellable (task);
- ctx->modem_cancellable = g_object_ref (modem_cancellable);
- ctx->cancelled_id = g_cancellable_connect (ctx->modem_cancellable,
- G_CALLBACK (modem_cancellable_cancelled),
- user_cancellable,
+ if (parent_cancellable) {
+ GCancellable *cancellable;
+
+ cancellable = g_task_get_cancellable (task);
+ ctx->parent_cancellable = g_object_ref (parent_cancellable);
+ ctx->cancelled_id = g_cancellable_connect (ctx->parent_cancellable,
+ G_CALLBACK (parent_cancellable_cancelled),
+ cancellable,
NULL);
}