From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5195] Make sure to read siginfo from signalfd
Date: Thu, 11 Sep 2008 14:32:27 +0000 [thread overview]
Message-ID: <E1KdnDf-00075d-FE@cvs.savannah.gnu.org> (raw)
Revision: 5195
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5195
Author: aliguori
Date: 2008-09-11 14:32:27 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
Make sure to read siginfo from signalfd
Otherwise, we'll idle at 100% cpu.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Modified Paths:
--------------
trunk/block-raw-posix.c
Modified: trunk/block-raw-posix.c
===================================================================
--- trunk/block-raw-posix.c 2008-09-11 14:18:56 UTC (rev 5194)
+++ trunk/block-raw-posix.c 2008-09-11 14:32:27 UTC (rev 5195)
@@ -449,7 +449,31 @@
{
RawAIOCB *acb, **pacb;
int ret;
+ size_t offset;
+ union {
+ struct qemu_signalfd_siginfo siginfo;
+ char buf[128];
+ } sig;
+ /* try to read from signalfd, don't freak out if we can't read anything */
+ offset = 0;
+ while (offset < 128) {
+ ssize_t len;
+
+ len = read(aio_sig_fd, sig.buf + offset, 128 - offset);
+ if (len == -1 && errno == EINTR)
+ continue;
+ if (len == -1 && errno == EAGAIN) {
+ /* there is no natural reason for this to happen,
+ * so we'll spin hard until we get everything just
+ * to be on the safe side. */
+ if (offset > 0)
+ continue;
+ }
+
+ offset += len;
+ }
+
for(;;) {
pacb = &first_aio;
for(;;) {
@@ -498,6 +522,9 @@
sigprocmask(SIG_BLOCK, &mask, NULL);
aio_sig_fd = qemu_signalfd(&mask);
+
+ fcntl(aio_sig_fd, F_SETFL, O_NONBLOCK);
+
#if !defined(QEMU_IMG) && !defined(QEMU_NBD)
qemu_set_fd_handler2(aio_sig_fd, NULL, qemu_aio_poll, NULL, NULL);
#endif
reply other threads:[~2008-09-11 14:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=E1KdnDf-00075d-FE@cvs.savannah.gnu.org \
--to=anthony@codemonkey.ws \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.