]> granicus.if.org Git - postgresql/commitdiff
Rename LWLockWaitUntilFree to LWLockAcquireOrWait.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Feb 2012 07:17:13 +0000 (09:17 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Feb 2012 07:17:13 +0000 (09:17 +0200)
LWLockAcquireOrWait makes it more clear that the lock is acquired if it's
free.

src/backend/access/transam/xlog.c
src/backend/storage/lmgr/lwlock.c
src/include/storage/lwlock.h

index 5e59c1ab1967a0516ef5e240286c36cab9ae2570..266c0decacac8c4386253e6f7bf2ce321b77c370 100644 (file)
@@ -2145,7 +2145,7 @@ XLogFlush(XLogRecPtr record)
                 * helps to maintain a good rate of group committing when the system
                 * is bottlenecked by the speed of fsyncing.
                 */
-               if (!LWLockWaitUntilFree(WALWriteLock, LW_EXCLUSIVE))
+               if (!LWLockAcquireOrWait(WALWriteLock, LW_EXCLUSIVE))
                {
                        /*
                         * The lock is now free, but we didn't acquire it yet. Before we
index 5d2873100de5130f268edd503040e4804bb44778..f1523760e5d6761abaaa08970a9b55db1014f0a4 100644 (file)
@@ -572,7 +572,7 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
 }
 
 /*
- * LWLockWaitUntilFree - Wait until a lock is free
+ * LWLockAcquireOrWait - Acquire lock, or wait until it's free
  *
  * The semantics of this function are a bit funky.  If the lock is currently
  * free, it is acquired in the given mode, and the function returns true.  If
@@ -586,14 +586,14 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
  * wake up, observe that their records have already been flushed, and return.
  */
 bool
-LWLockWaitUntilFree(LWLockId lockid, LWLockMode mode)
+LWLockAcquireOrWait(LWLockId lockid, LWLockMode mode)
 {
        volatile LWLock *lock = &(LWLockArray[lockid].lock);
        PGPROC     *proc = MyProc;
        bool            mustwait;
        int                     extraWaits = 0;
 
-       PRINT_LWDEBUG("LWLockWaitUntilFree", lockid, lock);
+       PRINT_LWDEBUG("LWLockAcquireOrWait", lockid, lock);
 
 #ifdef LWLOCK_STATS
        /* Set up local count state first time through in a given process */
@@ -665,7 +665,7 @@ LWLockWaitUntilFree(LWLockId lockid, LWLockMode mode)
                 * Wait until awakened.  Like in LWLockAcquire, be prepared for bogus
                 * wakups, because we share the semaphore with ProcWaitForSignal.
                 */
-               LOG_LWDEBUG("LWLockWaitUntilFree", lockid, "waiting");
+               LOG_LWDEBUG("LWLockAcquireOrWait", lockid, "waiting");
 
 #ifdef LWLOCK_STATS
                block_counts[lockid]++;
@@ -684,7 +684,7 @@ LWLockWaitUntilFree(LWLockId lockid, LWLockMode mode)
 
                TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(lockid, mode);
 
-               LOG_LWDEBUG("LWLockWaitUntilFree", lockid, "awakened");
+               LOG_LWDEBUG("LWLockAcquireOrWait", lockid, "awakened");
        }
        else
        {
@@ -702,7 +702,7 @@ LWLockWaitUntilFree(LWLockId lockid, LWLockMode mode)
        {
                /* Failed to get lock, so release interrupt holdoff */
                RESUME_INTERRUPTS();
-               LOG_LWDEBUG("LWLockWaitUntilFree", lockid, "failed");
+               LOG_LWDEBUG("LWLockAcquireOrWait", lockid, "failed");
                TRACE_POSTGRESQL_LWLOCK_WAIT_UNTIL_FREE_FAIL(lockid, mode);
        }
        else
index c684964a34fe25cd07646b6d48c4ac87d37cd544..57a4f66a1bbce75e2ada6390879489525a9484c3 100644 (file)
@@ -108,7 +108,7 @@ extern bool Trace_lwlocks;
 extern LWLockId LWLockAssign(void);
 extern void LWLockAcquire(LWLockId lockid, LWLockMode mode);
 extern bool LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode);
-extern bool LWLockWaitUntilFree(LWLockId lockid, LWLockMode mode);
+extern bool LWLockAcquireOrWait(LWLockId lockid, LWLockMode mode);
 extern void LWLockRelease(LWLockId lockid);
 extern void LWLockReleaseAll(void);
 extern bool LWLockHeldByMe(LWLockId lockid);