From: Stefan Hajnoczi <stefanha@redhat.com>
To: Marcel Apfelbaum <marcel.a@redhat.com>
Cc: armbru@redhat.com, qemu-devel@nongnu.org, aliguori@amazon.com,
afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 1/2] tests/libqtest: Fix possible deadlock in qtest initialization
Date: Mon, 10 Mar 2014 20:02:56 +0100 [thread overview]
Message-ID: <20140310190256.GA12263@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1394453534-24334-2-git-send-email-marcel.a@redhat.com>
On Mon, Mar 10, 2014 at 02:12:13PM +0200, Marcel Apfelbaum wrote:
> @@ -123,6 +125,11 @@ QTestState *qtest_init(const char *extra_args)
> sock = init_socket(socket_path);
> qmpsock = init_socket(qmp_socket_path);
>
> + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&socket_timeout,
> + sizeof(socket_timeout));
> + setsockopt(qmpsock, SOL_SOCKET, SO_RCVTIMEO, (void *)&socket_timeout,
> + sizeof(socket_timeout));
> +
Please move this into socket_accept() so qtest_init() doesn't need to
know about setsockopt() details. It should just get an fd or -errno
return value from socket_accept()...
> s->fd = socket_accept(sock);
> - s->qmp_fd = socket_accept(qmpsock);
> + if (s->fd >= 0) {
> + s->qmp_fd = socket_accept(qmpsock);
> + }
> unlink(socket_path);
> unlink(qmp_socket_path);
...then you can ensure that we unlink the sockets even on failure.
And then something like g_assert(s->fd >= 0 && s->qmp_fd >= 0) would be
fine. The process can abort() at this point.
next prev parent reply other threads:[~2014-03-10 19:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 12:12 [Qemu-devel] [PATCH 0/2] tests: Fix possible deadlock in qtest initialization Marcel Apfelbaum
2014-03-10 12:12 ` [Qemu-devel] [PATCH 1/2] tests/libqtest: " Marcel Apfelbaum
2014-03-10 19:02 ` Stefan Hajnoczi [this message]
2014-03-12 9:42 ` Markus Armbruster
2014-03-12 9:54 ` Marcel Apfelbaum
2014-03-10 12:12 ` [Qemu-devel] [PATCH 2/2] tests: check that qtest state is valid before starting the test Marcel Apfelbaum
2014-03-10 15:02 ` [Qemu-devel] [PATCH 0/2] tests: Fix possible deadlock in qtest initialization Stefan Hajnoczi
2014-03-10 15:21 ` Marcel Apfelbaum
2014-03-10 19:13 ` Stefan Hajnoczi
2014-03-11 10:11 ` Marcel Apfelbaum
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=20140310190256.GA12263@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=marcel.a@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).