diff options
author | kmacy <kmacy@FreeBSD.org> | 2008-08-20 03:27:12 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2008-08-20 03:27:12 +0000 |
commit | a87097dc9766ea224b6faf78cde4e14605fa0203 (patch) | |
tree | 6fbc2c0b0214eb58d1a05e112885d1742b20bcdc /sys/xen | |
parent | 01940f4e651c7f9086a04458e21966b4a28b7bfc (diff) | |
download | FreeBSD-src-a87097dc9766ea224b6faf78cde4e14605fa0203.zip FreeBSD-src-a87097dc9766ea224b6faf78cde4e14605fa0203.tar.gz |
Check for watch events when doing inline message processing
MFC after: 1 month
Diffstat (limited to 'sys/xen')
-rw-r--r-- | sys/xen/xenbus/xenbus_xs.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/sys/xen/xenbus/xenbus_xs.c b/sys/xen/xenbus/xenbus_xs.c index c4039f6..352ba20 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; } |