aboutsummaryrefslogtreecommitdiff
path: root/sys/xen
diff options
context:
space:
mode:
authorKip Macy <kmacy@FreeBSD.org>2008-08-20 03:27:12 +0000
committerKip Macy <kmacy@FreeBSD.org>2008-08-20 03:27:12 +0000
commit08279d945da4e711502b1fc63af5445772c484cb (patch)
tree6fbc2c0b0214eb58d1a05e112885d1742b20bcdc /sys/xen
parent1887d35f060e06496dcb3794b25c00622bbfcee8 (diff)
downloadsrc-08279d945da4e711502b1fc63af5445772c484cb.tar.gz
src-08279d945da4e711502b1fc63af5445772c484cb.zip
Check for watch events when doing inline message processing
MFC after: 1 month
Notes
Notes: svn path=/head/; revision=181893
Diffstat (limited to 'sys/xen')
-rw-r--r--sys/xen/xenbus/xenbus_xs.c55
1 files changed, 39 insertions, 16 deletions
diff --git a/sys/xen/xenbus/xenbus_xs.c b/sys/xen/xenbus/xenbus_xs.c
index c4039f616fbe..352ba20a1fc7 100644
--- a/sys/xen/xenbus/xenbus_xs.c
+++ b/sys/xen/xenbus/xenbus_xs.c
@@ -142,44 +142,67 @@ static int get_error(const char *errorstring)
return xsd_errors[i].errnum;
}
-extern int scheduler_running;
+extern void idle_block(void);
+extern void kdb_backtrace(void);
static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len)
{
struct xs_stored_msg *msg;
char *body;
- int i;
-
- if (scheduler_running == 0) {
+ int i, err;
+ enum xsd_sockmsg_type itype = *type;
+
+ printf("read_reply ");
+ if (xenbus_running == 0) {
/*
* Give other domain time to run :-/
*/
- for (i = 0; i < 100000; i++)
+ for (i = 0; i < 1000000 && (xenbus_running == 0); i++) {
+ err = xs_process_msg(type);
+
+ if ((err == 0)
+ && (*type != XS_WATCH_EVENT))
+ break;
+
HYPERVISOR_yield();
- xs_process_msg();
+ }
+
+ if (list_empty(&xs_state.reply_list)) {
+ printf("giving up and returning an error type=%d\n",
+ *type);
+ kdb_backtrace();
+ return (ERR_PTR(-1));
+ }
+
}
-
- spin_lock(&xs_state.reply_lock);
- while (list_empty(&xs_state.reply_list)) {
- spin_unlock(&xs_state.reply_lock);
- wait_event_interruptible(&xs_state.reply_waitq,
- !list_empty(&xs_state.reply_list));
- spin_lock(&xs_state.reply_lock);
+ mtx_lock(&xs_state.reply_lock);
+ if (xenbus_running) {
+ while (list_empty(&xs_state.reply_list)) {
+ mtx_unlock(&xs_state.reply_lock);
+ wait_event_interruptible(&xs_state.reply_waitq,
+ !list_empty(&xs_state.reply_list));
+
+ mtx_lock(&xs_state.reply_lock);
+ }
}
-
+
msg = TAILQ_FIRST(&xs_state.reply_list);
list_del(&xs_state.reply_list, msg);
- spin_unlock(&xs_state.reply_lock);
+ mtx_unlock(&xs_state.reply_lock);
+ printf("itype=%d htype=%d ", itype, msg->hdr.type);
*type = msg->hdr.type;
if (len)
*len = msg->hdr.len;
body = msg->u.reply.body;
kfree(msg);
-
+ if (len)
+ printf("len=%d\n", *len);
+ else
+ printf("len=NULL\n");
return body;
}