diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
commit | f7d30133221896638f7bf4f66c504255c4b14f48 (patch) | |
tree | 5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/pr/src/threads/prmon.c | |
parent | 26b297510a11758727438df4669357a2a2bc42ce (diff) | |
download | uxp-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz |
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/pr/src/threads/prmon.c')
-rw-r--r-- | nsprpub/pr/src/threads/prmon.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/nsprpub/pr/src/threads/prmon.c b/nsprpub/pr/src/threads/prmon.c index 36be8a9410..b7c526eea7 100644 --- a/nsprpub/pr/src/threads/prmon.c +++ b/nsprpub/pr/src/threads/prmon.c @@ -20,10 +20,12 @@ static void _PR_PostNotifyToMonitor(PRMonitor *mon, PRBool broadcast) /* mon->notifyTimes is protected by the monitor, so we don't need to * acquire mon->lock. */ - if (broadcast) + if (broadcast) { mon->notifyTimes = -1; - else if (mon->notifyTimes != -1) + } + else if (mon->notifyTimes != -1) { mon->notifyTimes += 1; + } } static void _PR_PostNotifiesFromMonitor(PRCondVar *cv, PRIntn times) @@ -55,7 +57,9 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor() PRMonitor *mon; PRStatus rv; - if (!_pr_initialized) _PR_ImplicitInitialization(); + if (!_pr_initialized) { + _PR_ImplicitInitialization(); + } mon = PR_NEWZAP(PRMonitor); if (mon == NULL) { @@ -65,20 +69,23 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor() rv = _PR_InitLock(&mon->lock); PR_ASSERT(rv == PR_SUCCESS); - if (rv != PR_SUCCESS) + if (rv != PR_SUCCESS) { goto error1; + } mon->owner = NULL; rv = _PR_InitCondVar(&mon->entryCV, &mon->lock); PR_ASSERT(rv == PR_SUCCESS); - if (rv != PR_SUCCESS) + if (rv != PR_SUCCESS) { goto error2; + } rv = _PR_InitCondVar(&mon->waitCV, &mon->lock); PR_ASSERT(rv == PR_SUCCESS); - if (rv != PR_SUCCESS) + if (rv != PR_SUCCESS) { goto error3; + } mon->notifyTimes = 0; mon->entryCount = 0; @@ -97,8 +104,9 @@ error1: PR_IMPLEMENT(PRMonitor*) PR_NewNamedMonitor(const char* name) { PRMonitor* mon = PR_NewMonitor(); - if (mon) + if (mon) { mon->name = name; + } return mon; } @@ -130,8 +138,9 @@ PR_IMPLEMENT(void) PR_EnterMonitor(PRMonitor *mon) PR_ASSERT(mon != NULL); PR_Lock(&mon->lock); if (mon->entryCount != 0) { - if (mon->owner == me) + if (mon->owner == me) { goto done; + } while (mon->entryCount != 0) { rv = PR_WaitCondVar(&mon->entryCV, PR_INTERVAL_NO_TIMEOUT); PR_ASSERT(rv == PR_SUCCESS); @@ -161,8 +170,9 @@ PR_IMPLEMENT(PRBool) PR_TestAndEnterMonitor(PRMonitor *mon) PR_ASSERT(mon != NULL); PR_Lock(&mon->lock); if (mon->entryCount != 0) { - if (mon->owner == me) + if (mon->owner == me) { goto done; + } rv = PR_Unlock(&mon->lock); PR_ASSERT(rv == PR_SUCCESS); return PR_FALSE; @@ -228,8 +238,9 @@ PR_IMPLEMENT(PRIntn) PR_GetMonitorEntryCount(PRMonitor *mon) PRIntn count = 0; PR_Lock(&mon->lock); - if (mon->owner == me) + if (mon->owner == me) { count = mon->entryCount; + } rv = PR_Unlock(&mon->lock); PR_ASSERT(rv == PR_SUCCESS); return count; @@ -337,10 +348,10 @@ PRUint32 _PR_MonitorToString(PRMonitor *mon, char *buf, PRUint32 buflen) PRUint32 nb; if (mon->owner) { - nb = PR_snprintf(buf, buflen, "[%p] owner=%d[%p] count=%ld", - mon, mon->owner->id, mon->owner, mon->entryCount); + nb = PR_snprintf(buf, buflen, "[%p] owner=%d[%p] count=%ld", + mon, mon->owner->id, mon->owner, mon->entryCount); } else { - nb = PR_snprintf(buf, buflen, "[%p]", mon); + nb = PR_snprintf(buf, buflen, "[%p]", mon); } return nb; } |