Re: [Spice-devel] [PATCH spice-server 06/10] Move thread/dispatching handling to RedChannel

2019-03-20 Thread Jonathon Jongsma
On Wed, 2019-03-20 at 09:59 +, Frediano Ziglio wrote:
> Currently channel threading/handling is spread between RedQxl,
> RedWorker and RedChannel.
> Move more to RedChannel simplify RedQxl and RedWorker.
> 
> Signed-off-by: Frediano Ziglio 
> ---
>  server/cursor-channel.c|   4 +-
>  server/cursor-channel.h|   4 +-
>  server/display-channel.c   |   2 +
>  server/display-channel.h   |   1 +
>  server/red-channel.c   | 111 +--
>  server/red-qxl.c   | 110 +-
>  server/red-replay-qxl.c|   3 -
>  server/red-stream-device.c |   2 +-
>  server/red-worker.c| 133 ++-
> --
>  server/red-worker.h|  46 ++---
>  10 files changed, 160 insertions(+), 256 deletions(-)
> 
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 4220084f..e8af01b0 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -228,7 +228,8 @@ static void
> cursor_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_it
>  }
>  
>  CursorChannel* cursor_channel_new(RedsState *server, int id,
> -  const SpiceCoreInterfaceInternal
> *core)
> +  const SpiceCoreInterfaceInternal
> *core,
> +  Dispatcher *dispatcher)
>  {
>  spice_debug("create cursor channel");
>  return g_object_new(TYPE_CURSOR_CHANNEL,
> @@ -238,6 +239,7 @@ CursorChannel* cursor_channel_new(RedsState
> *server, int id,
>  "id", id,
>  "migration-flags", 0,
>  "handle-acks", TRUE,
> +"dispatcher", dispatcher,
>  NULL);
>  }
>  
> diff --git a/server/cursor-channel.h b/server/cursor-channel.h
> index 603c2c0a..767325ea 100644
> --- a/server/cursor-channel.h
> +++ b/server/cursor-channel.h
> @@ -21,6 +21,7 @@
>  
>  #include "common-graphics-channel.h"
>  #include "red-parse-qxl.h"
> +#include "dispatcher.h"
>  
>  G_BEGIN_DECLS
>  
> @@ -57,7 +58,8 @@ GType cursor_channel_get_type(void) G_GNUC_CONST;
>   * CursorChannel thread.
>   */
>  CursorChannel* cursor_channel_new(RedsState *server, int id,
> -  const SpiceCoreInterfaceInternal
> *core);
> +  const SpiceCoreInterfaceInternal
> *core,
> +  Dispatcher *dispatcher);
>  
>  void cursor_channel_reset   (CursorChannel
> *cursor);
>  void cursor_channel_do_init (CursorChannel
> *cursor);
> diff --git a/server/display-channel.c b/server/display-channel.c
> index e179abfd..cb052bfc 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -2227,6 +2227,7 @@ static SpiceCanvas
> *image_surfaces_get(SpiceImageSurfaces *surfaces, uint32_t su
>  DisplayChannel* display_channel_new(RedsState *reds,
>  QXLInstance *qxl,
>  const SpiceCoreInterfaceInternal
> *core,
> +Dispatcher *dispatcher,
>  int migrate, int stream_video,
>  GArray *video_codecs,
>  uint32_t n_surfaces)
> @@ -2246,6 +2247,7 @@ DisplayChannel* display_channel_new(RedsState
> *reds,
> "n-surfaces", n_surfaces,
> "video-codecs", video_codecs,
> "handle-acks", TRUE,
> +   "dispatcher", dispatcher,
> NULL);
>  if (display) {
>  display_channel_set_stream_video(display, stream_video);
> diff --git a/server/display-channel.h b/server/display-channel.h
> index 948018cf..f64da0bd 100644
> --- a/server/display-channel.h
> +++ b/server/display-channel.h
> @@ -99,6 +99,7 @@ struct Drawable {
>  DisplayChannel*display_channel_new  
>  (RedsState *reds,
>  
>   QXLInstance *qxl,
>  
>   const SpiceCoreInterfaceInternal *core,
> +
>   Dispatcher *dispatcher,
>  
>   int migrate,
>  
>   int stream_video,
>  
>   GArray *video_codecs,
> diff --git a/server/red-channel.c b/server/red-channel.c
> index 1d88739e..8d05c971 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -70,6 +70,9 @@ struct RedChannelPrivate
>  uint32_t type;
>  uint32_t id;
>  
> +/* "core" interface to register events.
> + * Can be thread specific.

[Spice-devel] [PATCH spice-server 06/10] Move thread/dispatching handling to RedChannel

2019-03-20 Thread Frediano Ziglio
Currently channel threading/handling is spread between RedQxl,
RedWorker and RedChannel.
Move more to RedChannel simplify RedQxl and RedWorker.

Signed-off-by: Frediano Ziglio 
---
 server/cursor-channel.c|   4 +-
 server/cursor-channel.h|   4 +-
 server/display-channel.c   |   2 +
 server/display-channel.h   |   1 +
 server/red-channel.c   | 111 +--
 server/red-qxl.c   | 110 +-
 server/red-replay-qxl.c|   3 -
 server/red-stream-device.c |   2 +-
 server/red-worker.c| 133 ++---
 server/red-worker.h|  46 ++---
 10 files changed, 160 insertions(+), 256 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 4220084f..e8af01b0 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -228,7 +228,8 @@ static void cursor_channel_send_item(RedChannelClient *rcc, 
RedPipeItem *pipe_it
 }
 
 CursorChannel* cursor_channel_new(RedsState *server, int id,
-  const SpiceCoreInterfaceInternal *core)
+  const SpiceCoreInterfaceInternal *core,
+  Dispatcher *dispatcher)
 {
 spice_debug("create cursor channel");
 return g_object_new(TYPE_CURSOR_CHANNEL,
@@ -238,6 +239,7 @@ CursorChannel* cursor_channel_new(RedsState *server, int id,
 "id", id,
 "migration-flags", 0,
 "handle-acks", TRUE,
+"dispatcher", dispatcher,
 NULL);
 }
 
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 603c2c0a..767325ea 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -21,6 +21,7 @@
 
 #include "common-graphics-channel.h"
 #include "red-parse-qxl.h"
+#include "dispatcher.h"
 
 G_BEGIN_DECLS
 
@@ -57,7 +58,8 @@ GType cursor_channel_get_type(void) G_GNUC_CONST;
  * CursorChannel thread.
  */
 CursorChannel* cursor_channel_new(RedsState *server, int id,
-  const SpiceCoreInterfaceInternal *core);
+  const SpiceCoreInterfaceInternal *core,
+  Dispatcher *dispatcher);
 
 void cursor_channel_reset   (CursorChannel *cursor);
 void cursor_channel_do_init (CursorChannel *cursor);
diff --git a/server/display-channel.c b/server/display-channel.c
index e179abfd..cb052bfc 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2227,6 +2227,7 @@ static SpiceCanvas *image_surfaces_get(SpiceImageSurfaces 
*surfaces, uint32_t su
 DisplayChannel* display_channel_new(RedsState *reds,
 QXLInstance *qxl,
 const SpiceCoreInterfaceInternal *core,
+Dispatcher *dispatcher,
 int migrate, int stream_video,
 GArray *video_codecs,
 uint32_t n_surfaces)
@@ -2246,6 +2247,7 @@ DisplayChannel* display_channel_new(RedsState *reds,
"n-surfaces", n_surfaces,
"video-codecs", video_codecs,
"handle-acks", TRUE,
+   "dispatcher", dispatcher,
NULL);
 if (display) {
 display_channel_set_stream_video(display, stream_video);
diff --git a/server/display-channel.h b/server/display-channel.h
index 948018cf..f64da0bd 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -99,6 +99,7 @@ struct Drawable {
 DisplayChannel*display_channel_new   
(RedsState *reds,
   
QXLInstance *qxl,
   const 
SpiceCoreInterfaceInternal *core,
+  
Dispatcher *dispatcher,
   int 
migrate,
   int 
stream_video,
   GArray 
*video_codecs,
diff --git a/server/red-channel.c b/server/red-channel.c
index 1d88739e..8d05c971 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -70,6 +70,9 @@ struct RedChannelPrivate
 uint32_t type;
 uint32_t id;
 
+/* "core" interface to register events.
+ * Can be thread specific.
+ */
 SpiceCoreInterfaceInternal *core;
 gboolean handle_acks;
 
@@ -90,12 +93,29 @@ struct RedChannelPrivate
 // TODO: when different channel_clients are in different threads
 // from Channel -> need to protect!
 pthread_t thread_id;
+Dispatcher *dispatcher;
 RedsState