<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 17, 2017 at 9:56 AM, Dan Williams <span dir="ltr"><<a href="mailto:dcbw@redhat.com" target="_blank">dcbw@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, 2017-04-15 at 23:26 +0200, Aleksander Morgado wrote:<br>
> When the GCancellable is added to the GTask, we can use a single<br>
> method call to check for the task being cancelled, and complete it<br>
> right away if so.<br>
><br>
> This patch also clears up the logic in the Novatel plugin, where the<br>
> code was trying to return "TRUE" when the task was cancelled, but<br>
> wouldn't work as the check-cancellable flag in the GTask is TRUE by<br>
> default (i.e. when completing the GTask, if it was cancelled, a<br>
> G_IO_ERROR_CANCELLED would be returned by default, regardless of any<br>
> other return value set).<br>
><br>
> This patch also introduces a small variation of the logic in the<br>
> Cinterion plugin: instead of running SWWAN=0 before completing the<br>
> async action, the command is now sent just after completion of the<br>
> async action. This shouldn't be an issue, as the SWWAN result itself<br>
> is ignored.<br>
><br>
<br>
</span>Patch LGTM.<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>lgtm too</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> ---<br>
><br>
> Hey Ben,<br>
><br>
> What do you think of these changes? I believe we should start using<br>
> this where applicable, instead of the custom checks and errors.<br>
><br>
> ---<br>
>  plugins/cinterion/mm-<wbr>broadband-bearer-cinterion.c | 7 ++-----<br>
>  plugins/novatel/mm-common-<wbr>novatel.c               | 3 +--<br>
>  src/mm-auth-provider-polkit.<wbr>c                     | 6 +-----<br>
>  src/mm-iface-modem-signal.c  <wbr>                     | 6 +-----<br>
>  4 files changed, 5 insertions(+), 17 deletions(-)<br>
><br>
> diff --git a/plugins/cinterion/mm-<wbr>broadband-bearer-cinterion.c<br>
> b/plugins/cinterion/mm-<wbr>broadband-bearer-cinterion.c<br>
> index 741d2935..a1c699e9 100644<br>
> --- a/plugins/cinterion/mm-<wbr>broadband-bearer-cinterion.c<br>
> +++ b/plugins/cinterion/mm-<wbr>broadband-bearer-cinterion.c<br>
> @@ -343,10 +343,6 @@ handle_cancel_dial (GTask *task)<br>
>                               <wbr>      NULL,<br>
>                               <wbr>      NULL);<br>
>      g_free (command);<br>
> -<br>
> -    g_task_return_new_error (task, MM_CORE_ERROR,<br>
> MM_CORE_ERROR_CANCELLED,<br>
> -                             <wbr>"Connection operation has been<br>
> cancelled");<br>
> -    g_object_unref (task);<br>
>  }<br>
><br>
>  static void<br>
> @@ -357,8 +353,9 @@ dial_3gpp_context_step (GTask *task)<br>
>      ctx = (Dial3gppContext *) g_task_get_task_data (task);<br>
><br>
>      /* Check for cancellation */<br>
> -    if (g_cancellable_is_cancelled (g_task_get_cancellable (task)))<br>
> {<br>
> +    if (g_task_return_error_if_<wbr>cancelled (task)) {<br>
>          handle_cancel_dial (task);<br>
> +        g_object_unref (task);<br>
>          return;<br>
>      }<br>
><br>
> diff --git a/plugins/novatel/mm-common-<wbr>novatel.c<br>
> b/plugins/novatel/mm-common-<wbr>novatel.c<br>
> index 96d845f1..f8c78f51 100644<br>
> --- a/plugins/novatel/mm-common-<wbr>novatel.c<br>
> +++ b/plugins/novatel/mm-common-<wbr>novatel.c<br>
> @@ -87,10 +87,9 @@ custom_init_step (GTask *task)<br>
>      ctx = g_task_get_task_data (task);<br>
><br>
>      /* If cancelled, end */<br>
> -    if (g_cancellable_is_cancelled (g_task_get_cancellable (task)))<br>
> {<br>
> +    if (g_task_return_error_if_<wbr>cancelled (task)) {<br>
>          mm_dbg ("(Novatel) no need to keep on running custom init in<br>
> (%s)",<br>
>                  mm_port_get_<wbr>device (MM_PORT (ctx->port)));<br>
> -        g_task_return_boolean (task, TRUE);<br>
>          g_object_unref (task);<br>
>          return;<br>
>      }<br>
> diff --git a/src/mm-auth-provider-polkit.<wbr>c b/src/mm-auth-provider-<br>
> polkit.c<br>
> index 3b9b4250..7e88d67c 100644<br>
> --- a/src/mm-auth-provider-polkit.<wbr>c<br>
> +++ b/src/mm-auth-provider-polkit.<wbr>c<br>
> @@ -72,11 +72,7 @@ check_authorization_ready (PolkitAuthority<br>
> *authority,<br>
>      GError *error = NULL;<br>
>      AuthorizeContext *ctx;<br>
><br>
> -    if (g_cancellable_is_cancelled (g_task_get_cancellable (task)))<br>
> {<br>
> -        g_task_return_new_<wbr>error (task,<br>
> -                             <wbr>    MM_CORE_ERROR,<br>
> -                             <wbr>    MM_CORE_ERROR_CANCELLED,<br>
> -                             <wbr>    "PolicyKit authorization attempt<br>
> cancelled");<br>
> +    if (g_task_return_error_if_<wbr>cancelled (task)) {<br>
>          g_object_unref (task);<br>
>          return;<br>
>      }<br>
> diff --git a/src/mm-iface-modem-signal.c b/src/mm-iface-modem-<br>
> signal.c<br>
> index 9751b5d6..99096a95 100644<br>
> --- a/src/mm-iface-modem-signal.c<br>
> +++ b/src/mm-iface-modem-signal.c<br>
> @@ -418,11 +418,7 @@ interface_initialization_step (GTask *task)<br>
>      InitializationContext *ctx;<br>
><br>
>      /* Don't run new steps if we're cancelled */<br>
> -    if (g_cancellable_is_cancelled (g_task_get_cancellable (task)))<br>
> {<br>
> -        g_task_return_new_<wbr>error (task,<br>
> -                             <wbr>    MM_CORE_ERROR,<br>
> -                             <wbr>    MM_CORE_ERROR_CANCELLED,<br>
> -                             <wbr>    "Interface initialization<br>
> cancelled");<br>
> +    if (g_task_return_error_if_<wbr>cancelled (task)) {<br>
>          g_object_unref (task);<br>
>          return;<br>
>      }<br>
> --<br>
> 2.12.2<br>
</div></div></blockquote></div><br></div></div>