Index: trunk/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c
===================================================================
--- trunk/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c	(revision 5334)
+++ trunk/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c	(revision 5335)
@@ -59,14 +59,14 @@
     AssertPtrReturn(pEventMultiSem, VERR_INVALID_POINTER);
 
-    PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pEventMultiInt));
-    if (pEventMultiInt)
-    {
-        pEventMultiInt->u32Magic = RTSEMEVENTMULTI_MAGIC;
-        pEventMultiInt->cWaiters = 0;
-        pEventMultiInt->cWaking = 0;
-        pEventMultiInt->fSignaled = 0;
-        mutex_init(&pEventMultiInt->Mtx, "IPRT Multiple Release Event Semaphore", MUTEX_DRIVER, NULL);
-        cv_init(&pEventMultiInt->Cnd, "IPRT CV", CV_DRIVER, NULL);
-        *pEventMultiSem = pEventMultiInt;
+    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pThis));
+    if (pThis)
+    {
+        pThis->u32Magic = RTSEMEVENTMULTI_MAGIC;
+        pThis->cWaiters = 0;
+        pThis->cWaking = 0;
+        pThis->fSignaled = 0;
+        mutex_init(&pThis->Mtx, "IPRT Multiple Release Event Semaphore", MUTEX_DRIVER, NULL);
+        cv_init(&pThis->Cnd, "IPRT CV", CV_DRIVER, NULL);
+        *pEventMultiSem = pThis;
         return VINF_SUCCESS;
     }
@@ -79,28 +79,28 @@
     if (EventMultiSem == NIL_RTSEMEVENTMULTI)     /* don't bitch */
         return VERR_INVALID_HANDLE;
-    PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
-    AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
-    AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
-                    ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
-                    VERR_INVALID_HANDLE);
-
-    mutex_enter(&pEventMultiInt->Mtx);
-    ASMAtomicIncU32(&pEventMultiInt->u32Magic); /* make the handle invalid */
-    if (pEventMultiInt->cWaiters > 0)
+    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC,
+                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
+                    VERR_INVALID_HANDLE);
+
+    mutex_enter(&pThis->Mtx);
+    ASMAtomicIncU32(&pThis->u32Magic); /* make the handle invalid */
+    if (pThis->cWaiters > 0)
     {
         /* abort waiting thread, last man cleans up. */
-        ASMAtomicXchgU32(&pEventMultiInt->cWaking, pEventMultiInt->cWaking + pEventMultiInt->cWaiters);
-        cv_signal(&pEventMultiInt->Cnd);
-        mutex_exit(&pEventMultiInt->Mtx);
-    }
-    else if (pEventMultiInt->cWaking)
+        ASMAtomicXchgU32(&pThis->cWaking, pThis->cWaking + pThis->cWaiters);
+        cv_broadcast(&pThis->Cnd);
+        mutex_exit(&pThis->Mtx);
+    }
+    else if (pThis->cWaking)
         /* the last waking thread is gonna do the cleanup */
-        mutex_exit(&pEventMultiInt->Mtx);
+        mutex_exit(&pThis->Mtx);
     else
     {
-        mutex_exit(&pEventMultiInt->Mtx);
-        cv_destroy(&pEventMultiInt->Cnd);
-        mutex_destroy(&pEventMultiInt->Mtx);
-        RTMemFree(pEventMultiInt);
+        mutex_exit(&pThis->Mtx);
+        cv_destroy(&pThis->Cnd);
+        mutex_destroy(&pThis->Mtx);
+        RTMemFree(pThis);
     }
 
@@ -111,21 +111,21 @@
 RTDECL(int)  RTSemEventMultiSignal(RTSEMEVENTMULTI EventMultiSem)
 {
-    PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
-    AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
-    AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
-                    ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
-                    VERR_INVALID_HANDLE);
-
-    mutex_enter(&pEventMultiInt->Mtx);
-
-    ASMAtomicXchgU8(&pEventMultiInt->fSignaled, true);
-    if (pEventMultiInt->cWaiters > 0)
-    {
-        ASMAtomicXchgU32(&pEventMultiInt->cWaking, pEventMultiInt->cWaking + pEventMultiInt->cWaiters);
-        ASMAtomicXchgU32(&pEventMultiInt->cWaiters, 0);
-        cv_signal(&pEventMultiInt->Cnd);
-    }
-
-    mutex_exit(&pEventMultiInt->Mtx);
+    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC,
+                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
+                    VERR_INVALID_HANDLE);
+
+    mutex_enter(&pThis->Mtx);
+
+    ASMAtomicXchgU8(&pThis->fSignaled, true);
+    if (pThis->cWaiters > 0)
+    {
+        ASMAtomicXchgU32(&pThis->cWaking, pThis->cWaking + pThis->cWaiters);
+        ASMAtomicXchgU32(&pThis->cWaiters, 0);
+        cv_signal(&pThis->Cnd);
+    }
+
+    mutex_exit(&pThis->Mtx);
     return VINF_SUCCESS;
 }
@@ -134,13 +134,13 @@
 RTDECL(int)  RTSemEventMultiReset(RTSEMEVENTMULTI EventMultiSem)
 {
-    PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
-    AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
-    AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
-                    ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
-                    VERR_INVALID_HANDLE);
-
-    mutex_enter(&pEventMultiInt->Mtx);
-    ASMAtomicXchgU8(&pEventMultiInt->fSignaled, false);
-    mutex_exit(&pEventMultiInt->Mtx);
+    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC,
+                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
+                    VERR_INVALID_HANDLE);
+
+    mutex_enter(&pThis->Mtx);
+    ASMAtomicXchgU8(&pThis->fSignaled, false);
+    mutex_exit(&pThis->Mtx);
     return VINF_SUCCESS;
 }
@@ -150,13 +150,13 @@
 {
     int rc;
-    PRTSEMEVENTMULTIINTERNAL pEventMultiInt = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
-    AssertPtrReturn(pEventMultiInt, VERR_INVALID_HANDLE);
-    AssertMsgReturn(pEventMultiInt->u32Magic == RTSEMEVENTMULTI_MAGIC,
-                    ("pEventMultiInt=%p u32Magic=%#x\n", pEventMultiInt, pEventMultiInt->u32Magic),
-                    VERR_INVALID_HANDLE);
-
-    mutex_enter(&pEventMultiInt->Mtx);
-
-    if (pEventMultiInt->fSignaled)
+    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)EventMultiSem;
+    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
+    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC,
+                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
+                    VERR_INVALID_HANDLE);
+
+    mutex_enter(&pThis->Mtx);
+
+    if (pThis->fSignaled)
         rc = VINF_SUCCESS;
     else
@@ -175,32 +175,34 @@
         timeout += cTicks;
         
-        ASMAtomicIncU32(&pEventMultiInt->cWaiters);
-
-        /** @todo r=bird: Is this interruptible or non-interruptible? */
-        rc = cv_timedwait_sig(&pEventMultiInt->Cnd, &pEventMultiInt->Mtx, timeout);
+        ASMAtomicIncU32(&pThis->cWaiters);
+
+        if (fInterruptible)
+            rc = cv_timedwait_sig(&pThis->Cnd, &pThis->Mtx, timeout);
+        else
+            rc = cv_timedwait(&pThis->Cnd, &pThis->Mtx, timeout);
         if (rc > 0)
         {
             /* Retured due to call to cv_signal() or cv_broadcast() */
-            if (pEventMultiInt->u32Magic != RTSEMEVENT_MAGIC)
+            if (RT_LIKELY(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC))
+                rc = VINF_SUCCESS;
+            else
             {
                 rc = VERR_SEM_DESTROYED;
-                if (!ASMAtomicDecU32(&pEventMultiInt->cWaking))
+                if (!ASMAtomicDecU32(&pThis->cWaking))
                 {
-                    mutex_exit(&pEventMultiInt->Mtx);
-                    cv_destroy(&pEventMultiInt->Cnd);
-                    mutex_destroy(&pEventMultiInt->Mtx);
-                    RTMemFree(pEventMultiInt);
+                    mutex_exit(&pThis->Mtx);
+                    cv_destroy(&pThis->Cnd);
+                    mutex_destroy(&pThis->Mtx);
+                    RTMemFree(pThis);
                     return rc;
                 }
             }
-
-            ASMAtomicDecU32(&pEventMultiInt->cWaking);
-            rc = VINF_SUCCESS;
+            ASMAtomicDecU32(&pThis->cWaking);
         }
         else if (rc == -1)
         {
             /* Returned due to timeout being reached */
-            if (pEventMultiInt->cWaiters > 0)
-                ASMAtomicDecU32(&pEventMultiInt->cWaiters);
+            if (pThis->cWaiters > 0)
+                ASMAtomicDecU32(&pThis->cWaiters);
             rc = VERR_TIMEOUT;
         }
@@ -208,11 +210,11 @@
         {
             /* Returned due to pending signal */
-            if (pEventMultiInt->cWaiters > 0)
-                ASMAtomicDecU32(&pEventMultiInt->cWaiters);
+            if (pThis->cWaiters > 0)
+                ASMAtomicDecU32(&pThis->cWaiters);
             rc = VERR_INTERRUPTED;
         }
     }
 
-    mutex_exit(&pEventMultiInt->Mtx);
+    mutex_exit(&pThis->Mtx);
     return rc;
 }
