]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
vircommand: fix polling in virCommandProcessIO
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Tue, 21 Apr 2015 17:11:32 +0000 (20:11 +0300)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Wed, 22 Apr 2015 14:56:53 +0000 (17:56 +0300)
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.

src/util/vircommand.c

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