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

[libvirt] [PATCH 02/10] virnetclientstream: Propagate stream error messages to callback



If a stream notification message arives from the daemon side, the event
dispatcher only sets the error state for the stream but does not emit
the stream error event and the corresponding callback is not called.

This patch adds the emision of the event in the cause a stream error
(abortion) happens and the user may act on this using the event
callback.
---
 src/rpc/virnetclientstream.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 7e2d9ae..9049659 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -65,7 +65,6 @@ struct _virNetClientStream {
     int cbDispatch;
 };

-
 static void
 virNetClientStreamEventTimerUpdate(virNetClientStreamPtr st)
 {
@@ -76,7 +75,8 @@ virNetClientStreamEventTimerUpdate(virNetClientStreamPtr st)

     if (((st->incomingOffset || st->incomingEOF) &&
          (st->cbEvents & VIR_STREAM_EVENT_READABLE)) ||
-        (st->cbEvents & VIR_STREAM_EVENT_WRITABLE)) {
+        (st->cbEvents & VIR_STREAM_EVENT_WRITABLE) ||
+        (st->cbEvents & VIR_STREAM_EVENT_ERROR && st->err.code != VIR_ERR_OK)) {
         VIR_DEBUG("Enabling event timer");
         virEventUpdateTimeout(st->cbTimer, 0);
     } else {
@@ -85,7 +85,6 @@ virNetClientStreamEventTimerUpdate(virNetClientStreamPtr st)
     }
 }

-
 static void
 virNetClientStreamEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
 {
@@ -102,6 +101,10 @@ virNetClientStreamEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
     if (st->cb &&
         (st->cbEvents & VIR_STREAM_EVENT_WRITABLE))
         events |= VIR_STREAM_EVENT_WRITABLE;
+    if (st->cb &&
+       (st->cbEvents & VIR_STREAM_EVENT_ERROR) &&
+       st->err.code != VIR_ERR_OK)
+        events |= VIR_STREAM_EVENT_ERROR;

     VIR_DEBUG("Got Timer dispatch %d %d offset=%zu", events, st->cbEvents, st->incomingOffset);
     if (events) {
@@ -121,7 +124,6 @@ virNetClientStreamEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
     virMutexUnlock(&st->lock);
 }

-
 static void
 virNetClientStreamEventTimerFree(void *opaque)
 {
@@ -276,6 +278,8 @@ int virNetClientStreamSetError(virNetClientStreamPtr st,
 cleanup:
     xdr_free((xdrproc_t)xdr_virNetMessageError, (void*)&err);
     virMutexUnlock(&st->lock);
+    virNetClientStreamEventTimerUpdate(st);
+
     return ret;
 }

-- 
1.7.3.4


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