qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH] char-socket: hold chr_write_lock during tcp_chr_free_connection()
Date: Wed, 6 Feb 2019 14:00:03 +0100	[thread overview]
Message-ID: <36d0c208-d4c5-712b-aa76-40009b224be5@redhat.com> (raw)
In-Reply-To: <20190206124345.14942-1-berto@igalia.com>

On 06/02/19 13:43, Alberto Garcia wrote:
>          }
> @@ -449,7 +451,9 @@ static void tcp_chr_disconnect(Chardev *chr)
>      SocketChardev *s = SOCKET_CHARDEV(chr);
>      bool emit_close = s->connected;
>  
> +    qemu_mutex_lock(&chr->chr_write_lock);
>      tcp_chr_free_connection(chr);
> +    qemu_mutex_unlock(&chr->chr_write_lock);
>  
>      if (s->listener) {
>          qio_net_listener_set_client_func_full(s->listener, tcp_chr_accept,

Should operations on the listener also be protected?  I think that apart
from emitting the closed event itself everything in this function should
be protected by the lock.   The closed event should be pushed to the
GMainContext using an idle source (perhaps it's worth writing a wrapper
qemu_idle_add that takes a GMainContext, as the same idiom is already
present in pty_chr_state and qio_task_thread_worker).

socket_reconnect_timeout should also take the lock when freeing
s->reconnect_timer.

Paolo

  parent reply	other threads:[~2019-02-06 13:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06 12:43 [Qemu-devel] [RFC PATCH] char-socket: hold chr_write_lock during tcp_chr_free_connection() Alberto Garcia
2019-02-06 12:49 ` Daniel P. Berrangé
2019-02-06 12:52   ` Paolo Bonzini
2019-02-06 13:14     ` Daniel P. Berrangé
2019-02-06 13:01   ` Alberto Garcia
2019-02-06 13:00 ` Paolo Bonzini [this message]
2019-02-06 13:23   ` Alberto Garcia

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=36d0c208-d4c5-712b-aa76-40009b224be5@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=berto@igalia.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.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).