Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen/xen xbdback_disconnect() can be called twice, ...



details:   https://anonhg.NetBSD.org/src/rev/564ee56543d2
branches:  trunk
changeset: 771760:564ee56543d2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Dec 03 22:36:28 2011 +0000

description:
xbdback_disconnect() can be called twice,  from XenbusStateClosing then from
xbdback_xenbus_destroy(). The second call will wait forever as the first
already caused the xbd thread to exit.
Have xbdback_disconnect() check if we're already disconnected and if so,
do nothing.

diffstat:

 sys/arch/xen/xen/xbdback_xenbus.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (59 lines):

diff -r 597940aba1bd -r 564ee56543d2 sys/arch/xen/xen/xbdback_xenbus.c
--- a/sys/arch/xen/xen/xbdback_xenbus.c Sat Dec 03 16:25:49 2011 +0000
+++ b/sys/arch/xen/xen/xbdback_xenbus.c Sat Dec 03 22:36:28 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xbdback_xenbus.c,v 1.53 2011/11/24 18:34:56 joerg Exp $      */
+/*      $NetBSD: xbdback_xenbus.c,v 1.54 2011/12/03 22:36:28 bouyer Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.53 2011/11/24 18:34:56 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.54 2011/12/03 22:36:28 bouyer Exp $");
 
 #include <sys/atomic.h>
 #include <sys/buf.h>
@@ -305,7 +305,7 @@
 static int  xbdback_evthandler(void *);
 
 static int  xbdback_connect(struct xbdback_instance *);
-static int  xbdback_disconnect(struct xbdback_instance *);
+static void xbdback_disconnect(struct xbdback_instance *);
 static void xbdback_finish_disconnect(struct xbdback_instance *);
 
 static struct xbdback_instance *xbdif_lookup(domid_t, uint32_t);
@@ -662,16 +662,20 @@
 /*
  * Signal a xbdback thread to disconnect. Done in 'xenwatch' thread context.
  */
-static int
+static void
 xbdback_disconnect(struct xbdback_instance *xbdi)
 {
        
+       mutex_enter(&xbdi->xbdi_lock);
+       if (xbdi->xbdi_status == DISCONNECTED) {
+               mutex_exit(&xbdi->xbdi_lock);
+               return;
+       }
        hypervisor_mask_event(xbdi->xbdi_evtchn);
        event_remove_handler(xbdi->xbdi_evtchn, xbdback_evthandler,
            xbdi);
 
        /* signal thread that we want to disconnect, then wait for it */
-       mutex_enter(&xbdi->xbdi_lock);
        xbdi->xbdi_status = DISCONNECTING;
        cv_signal(&xbdi->xbdi_cv);
 
@@ -681,8 +685,6 @@
        mutex_exit(&xbdi->xbdi_lock);
 
        xenbus_switch_state(xbdi->xbdi_xbusd, NULL, XenbusStateClosing);
-
-       return 0;
 }
 
 static void



Home | Main Index | Thread Index | Old Index