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

Daniel P. Berrange berrange at redhat.com
Tue Oct 18 10:26:16 UTC 2011


On Wed, Oct 12, 2011 at 03:43:12PM +0200, Peter Krempa wrote:
> 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) {


You shouldn't be checking 'cbEvents & VIR_STREAM_EVENT_ERROR' (or HANGUP). Both
those event types are always enabled, whenever cbEvents is set WRITABLE or READABLE.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list