Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dce54fd

Browse files
committed
new semaphore api
1 parent b52999d commit dce54fd

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

arbiter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static void MtmScheduleHeartbeat()
340340
enable_timeout_after(heartbeat_timer, MtmHeartbeatSendTimeout);
341341
send_heartbeat = true;
342342
}
343-
PGSemaphoreUnlock(&Mtm->sendSemaphore);
343+
PGSemaphoreUnlock(Mtm->sendSemaphore);
344344
}
345345

346346
static void MtmSendHeartbeat()
@@ -741,7 +741,7 @@ static void MtmSender(Datum arg)
741741

742742
while (!stop) {
743743
MtmMessageQueue *curr, *next;
744-
PGSemaphoreLock(&Mtm->sendSemaphore);
744+
PGSemaphoreLock(Mtm->sendSemaphore);
745745
CHECK_FOR_INTERRUPTS();
746746

747747
if (ConfigReloadPending)

bgwpool.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ static void BgwPoolMainLoop(BgwPool* pool)
5959
ProcessConfigFile(PGC_SIGHUP);
6060
}
6161

62-
PGSemaphoreLock(&pool->available);
62+
PGSemaphoreLock(pool->available);
6363
SpinLockAcquire(&pool->lock);
6464
if (pool->shutdown) {
65-
PGSemaphoreUnlock(&pool->available);
65+
PGSemaphoreUnlock(pool->available);
6666
break;
6767
}
6868
size = *(int*)&pool->queue[pool->head];
@@ -85,7 +85,7 @@ static void BgwPoolMainLoop(BgwPool* pool)
8585
}
8686
if (pool->producerBlocked) {
8787
pool->producerBlocked = false;
88-
PGSemaphoreUnlock(&pool->overflow);
88+
PGSemaphoreUnlock(pool->overflow);
8989
pool->lastPeakTime = 0;
9090
}
9191
SpinLockRelease(&pool->lock);
@@ -108,10 +108,10 @@ void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, c
108108
elog(PANIC, "Failed to allocate memory for background workers pool: %lld bytes requested", (long64)queueSize);
109109
}
110110
pool->executor = executor;
111-
PGSemaphoreCreate(&pool->available);
112-
PGSemaphoreCreate(&pool->overflow);
113-
PGSemaphoreReset(&pool->available);
114-
PGSemaphoreReset(&pool->overflow);
111+
pool->available = PGSemaphoreCreate();
112+
pool->overflow = PGSemaphoreCreate();
113+
PGSemaphoreReset(pool->available);
114+
PGSemaphoreReset(pool->overflow);
115115
SpinLockInit(&pool->lock);
116116
pool->shutdown = false;
117117
pool->producerBlocked = false;
@@ -215,7 +215,7 @@ void BgwPoolExecute(BgwPool* pool, void* work, size_t size)
215215
}
216216
pool->producerBlocked = true;
217217
SpinLockRelease(&pool->lock);
218-
PGSemaphoreLock(&pool->overflow);
218+
PGSemaphoreLock(pool->overflow);
219219
SpinLockAcquire(&pool->lock);
220220
} else {
221221
pool->pending += 1;
@@ -236,7 +236,7 @@ void BgwPoolExecute(BgwPool* pool, void* work, size_t size)
236236
if (pool->tail == pool->size) {
237237
pool->tail = 0;
238238
}
239-
PGSemaphoreUnlock(&pool->available);
239+
PGSemaphoreUnlock(pool->available);
240240
break;
241241
}
242242
}
@@ -248,6 +248,6 @@ void BgwPoolStop(BgwPool* pool)
248248
SpinLockAcquire(&pool->lock);
249249
pool->shutdown = true;
250250
SpinLockRelease(&pool->lock);
251-
PGSemaphoreUnlock(&pool->available);
252-
PGSemaphoreUnlock(&pool->overflow);
251+
PGSemaphoreUnlock(pool->available);
252+
PGSemaphoreUnlock(pool->overflow);
253253
}

bgwpool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ typedef struct
2525
{
2626
BgwPoolExecutor executor;
2727
volatile slock_t lock;
28-
PGSemaphoreData available;
29-
PGSemaphoreData overflow;
28+
PGSemaphore available;
29+
PGSemaphore overflow;
3030
size_t head;
3131
size_t tail;
3232
size_t size;

multimaster.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ void MtmSendMessage(MtmArbiterMessage* msg)
16941694
Mtm->sendQueue = mq;
16951695
if (sendQueue == NULL) {
16961696
/* signal semaphore only once for the whole list */
1697-
PGSemaphoreUnlock(&Mtm->sendSemaphore);
1697+
PGSemaphoreUnlock(Mtm->sendSemaphore);
16981698
}
16991699
}
17001700
SpinLockRelease(&Mtm->queueSpinlock);
@@ -2547,8 +2547,8 @@ static void MtmInitialize()
25472547
Mtm->nodes[MtmNodeId-1].originId = DoNotReplicateId;
25482548
/* All transaction originated from the current node should be ignored during recovery */
25492549
Mtm->nodes[MtmNodeId-1].restartLSN = (lsn_t)PG_UINT64_MAX;
2550-
PGSemaphoreCreate(&Mtm->sendSemaphore);
2551-
PGSemaphoreReset(&Mtm->sendSemaphore);
2550+
Mtm->sendSemaphore = PGSemaphoreCreate();
2551+
PGSemaphoreReset(Mtm->sendSemaphore);
25522552
SpinLockInit(&Mtm->queueSpinlock);
25532553
BgwPoolInit(&Mtm->pool, MtmExecutor, MtmDatabaseName, MtmDatabaseUser, MtmQueueSize, MtmWorkers);
25542554
RegisterXactCallback(MtmXactCallback, NULL);

multimaster.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ typedef struct
292292
MtmNodeStatus status; /* Status of this node */
293293
int recoverySlot; /* NodeId of recovery slot or 0 if none */
294294
volatile slock_t queueSpinlock; /* spinlock used to protect sender queue */
295-
PGSemaphoreData sendSemaphore; /* semaphore used to notify mtm-sender about new responses to coordinator */
295+
PGSemaphore sendSemaphore; /* semaphore used to notify mtm-sender about new responses to coordinator */
296296
LWLockPadded *locks; /* multimaster lock tranche */
297297
TransactionId oldestXid; /* XID of oldest transaction visible by any active transaction (local or global) */
298298
nodemask_t disabledNodeMask; /* Bitmask of disabled nodes */

0 commit comments

Comments
 (0)