[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 7/7] Fix busy-wait loop on closed file descriptor



When closing open streams after a client quits, the event
callback was not removed. This mean that poll() was using
a closed FD and returning POLLNVAL in a busy-wait loop.

* daemon/stream.c: Disconnect stream callbacks
---
 daemon/stream.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/daemon/stream.c b/daemon/stream.c
index d64fe73..cac54ea 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -108,6 +108,7 @@ remoteStreamEvent(virStreamPtr st, int events, void *opaque)
         remote_error rerr;
         memset(&rerr, 0, sizeof rerr);
         stream->closed = 1;
+        virStreamEventRemoveCallback(stream->st);
         virStreamAbort(stream->st);
         if (events & VIR_STREAM_EVENT_HANGUP)
             remoteDispatchFormatError(&rerr, "%s", _("stream had unexpected termination"));
@@ -345,8 +346,10 @@ remoteRemoveClientStream(struct qemud_client *client,
         }
     }
 
-    if (!stream->closed)
+    if (!stream->closed) {
+        virStreamEventRemoveCallback(stream->st);
         virStreamAbort(stream->st);
+    }
 
     while (curr) {
         if (curr == stream) {
@@ -429,6 +432,7 @@ remoteStreamHandleFinish(struct qemud_client *client,
     memset(&rerr, 0, sizeof rerr);
 
     stream->closed = 1;
+    virStreamEventRemoveCallback(stream->st);
     ret = virStreamFinish(stream->st);
 
     if (ret < 0) {
@@ -462,6 +466,7 @@ remoteStreamHandleAbort(struct qemud_client *client,
     memset(&rerr, 0, sizeof rerr);
 
     stream->closed = 1;
+    virStreamEventRemoveCallback(stream->st);
     virStreamAbort(stream->st);
 
     if (msg->hdr.status == REMOTE_ERROR)
-- 
1.7.2.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]