From b581c14c32881053dcc5d49262bb7d7ad7644ac9 Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Mon, 11 Jan 2016 16:34:50 +0000 Subject: Do not fail when receiving an empty reply (or directory node) in xs_intr() but put an empty message in the queue. This prevents xs_reply() from being stuck in an endless loop because it expectes a message in the queue to break out of it. Depends on mikeb@'s previous commit because it would otherwise panic on trying to cleanup the empty message. OK mikeb@ --- sys/dev/pv/xenstore.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/pv/xenstore.c b/sys/dev/pv/xenstore.c index 654602ff745..5e7f24d0f11 100644 --- a/sys/dev/pv/xenstore.c +++ b/sys/dev/pv/xenstore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xenstore.c,v 1.13 2016/01/11 16:14:16 mikeb Exp $ */ +/* $OpenBSD: xenstore.c,v 1.14 2016/01/11 16:34:49 reyk Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -559,9 +559,6 @@ xs_intr(void *arg) memcpy(&xsm->xsm_hdr, &xmh, sizeof(xmh)); xs->xs_rmsg = xsm; - - if (avail == 0) - goto out; } if (xsm->xsm_hdr.xmh_len > xsm->xsm_dlen) @@ -570,11 +567,16 @@ xs_intr(void *arg) xsm->xsm_hdr.xmh_rid); len = MIN(xsm->xsm_hdr.xmh_len - xsm->xsm_read, avail); - if ((len = xs_ring_get(xs, &xsm->xsm_data[xsm->xsm_read], len)) <= 0) { - printf("%s: read failure %d\n", sc->sc_dev.dv_xname, len); - goto out; + if (len) { + /* Get data if reply is not empty */ + if ((len = xs_ring_get(xs, + &xsm->xsm_data[xsm->xsm_read], len)) <= 0) { + printf("%s: read failure %d\n", sc->sc_dev.dv_xname, + len); + goto out; + } + xsm->xsm_read += len; } - xsm->xsm_read += len; /* Notify reader that we've managed to read the whole message */ if (xsm->xsm_read == xsm->xsm_hdr.xmh_len) { -- cgit v1.2.3