MCPcopy Create free account
hub / github.com/apache/cloudberry / ConditionalAcquireContentLock

Function ConditionalAcquireContentLock

src/backend/storage/buffer/bufmgr.c:560–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

558}
559
560static inline bool ConditionalAcquireContentLock(volatile BufferDesc *buf,
561 LWLockMode mode)
562{
563#ifdef MPROTECT_BUFFERS
564 const bool newAcquisition =
565 !LWLockHeldByMe(BufferDescriptorGetContentLock(buf));
566
567 if (LWLockConditionalAcquire(BufferDescriptorGetContentLock(buf), mode))
568 {
569 /* new acquisition of lock, allow read/write memory access */
570 if (newAcquisition)
571 BufferMProtect( buf, PROT_READ | PROT_WRITE );
572 return true;
573 }
574 return false;
575#else
576 return LWLockConditionalAcquire(BufferDescriptorGetContentLock(buf), mode);
577#endif
578}
579
580/*
581 * Implementation of PrefetchBuffer() for shared buffers.

Callers 2

BufferAllocFunction · 0.85
ConditionalLockBufferFunction · 0.85

Calls 3

LWLockHeldByMeFunction · 0.85
LWLockConditionalAcquireFunction · 0.85
BufferMProtectFunction · 0.85

Tested by

no test coverage detected