From: Alon Levy <alevy@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, spice-devel@freedesktop.org
Subject: Re: [Qemu-devel] [Spice-devel] [PATCH] server: don't call reds_stream_free from worker thread context
Date: Fri, 2 Sep 2011 22:27:06 +0300 [thread overview]
Message-ID: <20110902192633.GE27006@bow> (raw)
In-Reply-To: <1314976794-31931-1-git-send-email-kraxel@redhat.com>
On Fri, Sep 02, 2011 at 05:19:54PM +0200, Gerd Hoffmann wrote:
> reds_stream_free() may call the channel_event callback which is not
> supposed to be callsed from worker thread context. This patch moves
> the reds_stream_free call for the display channel from the worker to
> the dispatcher to fix this issue.
>
Looks good. I told Luiz that this would be harder to fix in spice-server,
and so I take it back - seems to be easier to fix in spice-server actually.
But still the possible problem of other users in qemu of monitor that don't
make sure to use the main thread remains.
> [ Note: not tested yet, against 0.8 branch, sending out for review &
> comments nevertheless ]
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> server/red_dispatcher.c | 5 +++++
> server/red_worker.c | 3 +--
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
> index f74b13e..801a575 100644
> --- a/server/red_dispatcher.c
> +++ b/server/red_dispatcher.c
> @@ -51,6 +51,7 @@ struct RedDispatcher {
> int y_res;
> int use_hardware_cursor;
> RedDispatcher *next;
> + RedsStream *stream;
> RedWorkerMessage async_message;
> pthread_mutex_t async_lock;
> QXLDevSurfaceCreate surface_create;
> @@ -81,6 +82,7 @@ static void red_dispatcher_set_peer(Channel *channel, RedsStream *stream, int mi
>
> red_printf("");
> dispatcher = (RedDispatcher *)channel->data;
> + dispatcher->stream = stream;
> RedWorkerMessage message = RED_WORKER_MESSAGE_DISPLAY_CONNECT;
> write_message(dispatcher->channel, &message);
> send_data(dispatcher->channel, &stream, sizeof(RedsStream *));
> @@ -93,6 +95,9 @@ static void red_dispatcher_shutdown_peer(Channel *channel)
> red_printf("");
> RedWorkerMessage message = RED_WORKER_MESSAGE_DISPLAY_DISCONNECT;
> write_message(dispatcher->channel, &message);
> + read_message(dispatcher->channel, &message);
> + ASSERT(message == RED_WORKER_MESSAGE_READY);
> + reds_stream_free(dispatcher->stream);
> }
>
> static void red_dispatcher_migrate(Channel *channel)
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 5f07803..f77b0f2 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -8486,8 +8486,6 @@ static void red_disconnect_channel(RedChannel *channel)
> {
> channel_release_res(channel);
> red_pipe_clear(channel);
> - reds_stream_free(channel->stream);
> - channel->stream = NULL;
> channel->send_data.blocked = FALSE;
> channel->send_data.size = channel->send_data.pos = 0;
> spice_marshaller_reset(channel->send_data.marshaller);
> @@ -10060,6 +10058,7 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
> case RED_WORKER_MESSAGE_CURSOR_DISCONNECT:
> red_printf("cursor disconnect");
> red_disconnect_cursor((RedChannel *)worker->cursor_channel);
> + write_ready = 1;
> break;
> case RED_WORKER_MESSAGE_CURSOR_MIGRATE:
> red_printf("cursor migrate");
> --
> 1.7.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
next prev parent reply other threads:[~2011-09-02 19:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-02 15:19 [Qemu-devel] [PATCH] server: don't call reds_stream_free from worker thread context Gerd Hoffmann
2011-09-02 19:27 ` Alon Levy [this message]
2011-09-04 8:43 ` [Qemu-devel] [Spice-devel] " Yonit Halperin
2011-09-05 9:02 ` Gerd Hoffmann
2011-09-05 10:47 ` Alon Levy
2011-09-05 13:29 ` Gerd Hoffmann
2011-09-05 13:44 ` Alon Levy
2011-09-05 13:45 ` Alon Levy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110902192633.GE27006@bow \
--to=alevy@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=spice-devel@freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).