From: John Wolfe Date: Tue, 22 Dec 2020 20:22:03 +0000 (-0800) Subject: Changes to a common source file not applicable to open-vm-tools. X-Git-Tag: stable-11.3.0~201 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b2d29f394066714ac0131c9904c01a5430ce16d;p=thirdparty%2Fopen-vm-tools.git Changes to a common source file not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/lock/ulSema.c b/open-vm-tools/lib/lock/ulSema.c index aabb087cc..f0984a19c 100644 --- a/open-vm-tools/lib/lock/ulSema.c +++ b/open-vm-tools/lib/lock/ulSema.c @@ -118,54 +118,48 @@ MXUserTimedDown(NativeSemaphore *sema, // IN: uint64 waitTimeNS, // IN: Bool *downOccurred) // OUT: { - int err; - DWORD status; - const uint64 maxWaitTimeMS = (uint64) 0x7FFFFFFF; - uint64 waitTimeMS = CEILING(waitTimeNS, (uint64) MXUSER_A_MILLION); - - if (waitTimeMS > maxWaitTimeMS) { - waitTimeMS = maxWaitTimeMS; - } - - status = WaitForSingleObject(*sema, (int) waitTimeMS); - - switch (status) { - case WAIT_OBJECT_0: // The down (decrement) occurred - *downOccurred = TRUE; - err = 0; - break; - - case WAIT_TIMEOUT: // Timed out; the down (decrement) did not occur - *downOccurred = FALSE; - err = 0; - break; - - default: // Something really terrible has happened... - Panic("%s: WaitForSingleObject return value %x\n", - __FUNCTION__, status); - } - - return err; + int err; + DWORD status; + const uint64 maxWaitTimeMS = (uint64) 0x7FFFFFFF; + uint64 waitTimeMS = CEILING(waitTimeNS, (uint64) MXUSER_A_MILLION); + + if (waitTimeMS > maxWaitTimeMS) { + waitTimeMS = maxWaitTimeMS; + } + + status = WaitForSingleObject(*sema, (DWORD) waitTimeMS); + + switch (status) { + case WAIT_OBJECT_0: // The down (decrement) occurred + *downOccurred = TRUE; + err = 0; + break; + + case WAIT_TIMEOUT: // Timed out; the down (decrement) did not occur + *downOccurred = FALSE; + err = 0; + break; + + default: // Something really terrible has happened... + Panic("%s: WaitForSingleObject return value %x\n", + __FUNCTION__, status); + } + + return err; } static int MXUserDown(NativeSemaphore *sema) // IN: { - int err; - Bool downOccurred; + DWORD status = WaitForSingleObject(*sema, INFINITE); - /* - * Use an infinite timed wait to implement down. If the timed down - * succeeds, assert that the down actually occurred. - */ - - err = MXUserTimedDown(sema, INFINITE, &downOccurred); - - if (err == 0) { - ASSERT(downOccurred); + /* The down (decrement) *HAD BETTER HAVE* occurred */ + if (status != WAIT_OBJECT_0) { + Panic("%s: WaitForSingleObject return value %x\n", + __FUNCTION__, status); } - return err; + return 0; } static int