[spice-gtk] file-transfer-task: emit signals in main context

Submitted by Jakub Janku on June 24, 2019, 9:03 a.m.

Details

Message ID 20190624090314.21734-1-jjanku@redhat.com
State Accepted
Commit 2261e50a6411c58ab6fdaf02b04acfb54aebf936
Headers show
Series "file-transfer-task: emit signals in main context" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Jakub Janku June 24, 2019, 9:03 a.m.
Some parts of the internal file transfer task API
can be invoked in the coroutine context, so in these cases
use g_coroutine_signal_emit and g_coroutine_object_notify.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
---
 src/spice-file-transfer-task.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
index d0170da..90f31db 100644
--- a/src/spice-file-transfer-task.c
+++ b/src/spice-file-transfer-task.c
@@ -327,7 +327,7 @@  void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
                                self);
     self->pending = TRUE;
 signal:
-    g_signal_emit(self, task_signals[SIGNAL_FINISHED], 0, self->error);
+    g_coroutine_signal_emit(self, task_signals[SIGNAL_FINISHED], 0, self->error);
     /* SpiceFileTransferTask unref is done after input stream is closed */
 }
 
@@ -433,8 +433,8 @@  void spice_file_transfer_task_read_async(SpiceFileTransferTask *self,
     /* Notify the progress prior the read to make the info be related to the
      * data that was already sent. To notify the 100% (completed), channel-main
      * should call read-async when it expects EOF. */
-    g_object_notify(G_OBJECT(self), "progress");
-    g_object_notify(G_OBJECT(self), "transferred-bytes");
+    g_coroutine_object_notify(G_OBJECT(self), "progress");
+    g_coroutine_object_notify(G_OBJECT(self), "transferred-bytes");
 
     task = g_task_new(self, self->cancellable, callback, userdata);
 

Comments

> 
> Some parts of the internal file transfer task API

I would expect "Most" of them as the agent messages are from the main
channel.

> can be invoked in the coroutine context, so in these cases
> use g_coroutine_signal_emit and g_coroutine_object_notify.
> 

I would add the "why", I suppose these signals are expected to be
run in the main context. The question is why they should be run in
the main context. They are not different thread, the only difference
will be the stack they will use.

> Signed-off-by: Jakub Janků <jjanku@redhat.com>
> ---
>  src/spice-file-transfer-task.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
> index d0170da..90f31db 100644
> --- a/src/spice-file-transfer-task.c
> +++ b/src/spice-file-transfer-task.c
> @@ -327,7 +327,7 @@ void
> spice_file_transfer_task_completed(SpiceFileTransferTask *self,
>                                 self);
>      self->pending = TRUE;
>  signal:
> -    g_signal_emit(self, task_signals[SIGNAL_FINISHED], 0, self->error);
> +    g_coroutine_signal_emit(self, task_signals[SIGNAL_FINISHED], 0,
> self->error);
>      /* SpiceFileTransferTask unref is done after input stream is closed */
>  }
>  
> @@ -433,8 +433,8 @@ void
> spice_file_transfer_task_read_async(SpiceFileTransferTask *self,
>      /* Notify the progress prior the read to make the info be related to the
>       * data that was already sent. To notify the 100% (completed),
>       channel-main
>       * should call read-async when it expects EOF. */
> -    g_object_notify(G_OBJECT(self), "progress");
> -    g_object_notify(G_OBJECT(self), "transferred-bytes");
> +    g_coroutine_object_notify(G_OBJECT(self), "progress");
> +    g_coroutine_object_notify(G_OBJECT(self), "transferred-bytes");
>  
>      task = g_task_new(self, self->cancellable, callback, userdata);
>  

Otherwise patch looks good.

Frediano