]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircommand: fix polling in virCommandProcessIO
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Tue, 21 Apr 2015 17:11:32 +0000 (20:11 +0300)
committerCole Robinson <crobinso@redhat.com>
Tue, 28 Apr 2015 15:26:47 +0000 (11:26 -0400)
When running on FreeBSD, there's a bug in virCommandProcessIO
polling that is triggered by the commandtest.

A test that triggers EPIPE in commandtest (named "test20") hungs
forever on FreeBSD.

Apparently, this happens because FreeBSD sets POLLHUP flag on revents
when stdin in closed. And as the current implementation only checks for
POLLOUT and POLLERR, it ends up looping forever inside
virCommandProcessIO and not trying to do one more write() that would
trigger EPIPE.

To fix that check for the POLLHUP flag along with POLLOUT and POLLERR.

(cherry picked from commit e34cccf783983e1b19f139bde873e950424a8778)

src/util/vircommand.c

index 6527d85e58ca7b751c15ac9e6658baef0245562d..c1b2e225bad31d6c0bfeb3c247a06f36918fe8c7 100644 (file)
@@ -2073,7 +2073,7 @@ virCommandProcessIO(virCommandPtr cmd)
                 }
             }
 
-            if (fds[i].revents & (POLLOUT | POLLERR) &&
+            if (fds[i].revents & (POLLOUT | POLLHUP | POLLERR) &&
                 fds[i].fd == cmd->inpipe) {
                 int done;