Non-volatile variables used for spinlock manipulation - Mailing list pgsql-hackers

From Antonin Houska
Subject Non-volatile variables used for spinlock manipulation
Date
Msg-id 23591.1441361986@localhost
Whole thread Raw
Responses Re: Non-volatile variables used for spinlock manipulation
List pgsql-hackers
Since SpinLockAcquire() / SpinLockRelease() macros usually reference variables
declared as volatile, I wonder if the following changes should be applied.

--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at

diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c
index 0e60dbc..256d09d 100644
--- a/src/backend/storage/ipc/shm_mq.c
+++ b/src/backend/storage/ipc/shm_mq.c
@@ -195,11 +195,11 @@ shm_mq_set_receiver(shm_mq *mq, PGPROC *proc)
     volatile shm_mq *vmq = mq;
     PGPROC       *sender;

-    SpinLockAcquire(&mq->mq_mutex);
+    SpinLockAcquire(&vmq->mq_mutex);
     Assert(vmq->mq_receiver == NULL);
     vmq->mq_receiver = proc;
     sender = vmq->mq_sender;
-    SpinLockRelease(&mq->mq_mutex);
+    SpinLockRelease(&vmq->mq_mutex);

     if (sender != NULL)
         SetLatch(&sender->procLatch);
@@ -214,11 +214,11 @@ shm_mq_set_sender(shm_mq *mq, PGPROC *proc)
     volatile shm_mq *vmq = mq;
     PGPROC       *receiver;

-    SpinLockAcquire(&mq->mq_mutex);
+    SpinLockAcquire(&vmq->mq_mutex);
     Assert(vmq->mq_sender == NULL);
     vmq->mq_sender = proc;
     receiver = vmq->mq_receiver;
-    SpinLockRelease(&mq->mq_mutex);
+    SpinLockRelease(&vmq->mq_mutex);

     if (receiver != NULL)
         SetLatch(&receiver->procLatch);
@@ -233,9 +233,9 @@ shm_mq_get_receiver(shm_mq *mq)
     volatile shm_mq *vmq = mq;
     PGPROC       *receiver;

-    SpinLockAcquire(&mq->mq_mutex);
+    SpinLockAcquire(&vmq->mq_mutex);
     receiver = vmq->mq_receiver;
-    SpinLockRelease(&mq->mq_mutex);
+    SpinLockRelease(&vmq->mq_mutex);

     return receiver;
 }
@@ -249,9 +249,9 @@ shm_mq_get_sender(shm_mq *mq)
     volatile shm_mq *vmq = mq;
     PGPROC       *sender;

-    SpinLockAcquire(&mq->mq_mutex);
+    SpinLockAcquire(&vmq->mq_mutex);
     sender = vmq->mq_sender;
-    SpinLockRelease(&mq->mq_mutex);
+    SpinLockRelease(&vmq->mq_mutex);

     return sender;
 }

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Declarative partitioning
Next
From: Etsuro Fujita
Date:
Subject: Re: Foreign join pushdown vs EvalPlanQual