[PATCH 2/2] libmbim-glib: mbim-device: Decouple logic for cancellable from timeout when storing transaction
Aleksander Morgado
aleksander at aleksander.es
Thu Feb 6 11:22:18 PST 2014
On 05/02/14 20:12, Greg Suarez wrote:
> Decouple the logic for connecting a cancellable from adding a timeout.
> Also check if the cancellable has been connected already.
>
> Signed-off-by: Greg Suarez <gpsuarez2512 at gmail.com>
> ---
Pushed, thanks.
> src/libmbim-glib/mbim-device.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/src/libmbim-glib/mbim-device.c b/src/libmbim-glib/mbim-device.c
> index ef47b7e..6f965e9 100644
> --- a/src/libmbim-glib/mbim-device.c
> +++ b/src/libmbim-glib/mbim-device.c
> @@ -272,19 +272,19 @@ device_store_transaction (MbimDevice *self,
> tr->timeout_id = g_timeout_add (timeout_ms,
> (GSourceFunc)transaction_timed_out,
> tr->wait_ctx);
> + }
>
> - if (tr->cancellable) {
> - tr->cancellable_id = g_cancellable_connect (tr->cancellable,
> - (GCallback)transaction_cancelled,
> - tr->wait_ctx,
> - NULL);
> - if (!tr->cancellable_id) {
> - g_set_error_literal (error,
> - MBIM_CORE_ERROR,
> - MBIM_CORE_ERROR_ABORTED,
> - "Request is already cancelled");
> - return FALSE;
> - }
> + if (tr->cancellable && !tr->cancellable_id) {
> + tr->cancellable_id = g_cancellable_connect (tr->cancellable,
> + (GCallback)transaction_cancelled,
> + tr->wait_ctx,
> + NULL);
> + if (!tr->cancellable_id) {
> + g_set_error_literal (error,
> + MBIM_CORE_ERROR,
> + MBIM_CORE_ERROR_ABORTED,
> + "Request is already cancelled");
> + return FALSE;
> }
> }
>
>
--
Aleksander
http://aleksander.es
More information about the libmbim-devel
mailing list