|
45 | 45 | #include "storage/proc.h"
|
46 | 46 | #include "storage/procsignal.h"
|
47 | 47 | #include "storage/shmem.h"
|
48 |
| -#include "storage/spin.h" |
49 | 48 | #include "utils/guc.h"
|
50 | 49 | #include "utils/memutils.h"
|
51 | 50 | #include "utils/ps_status.h"
|
@@ -83,11 +82,9 @@ typedef struct PgArchData
|
83 | 82 | int pgprocno; /* pgprocno of archiver process */
|
84 | 83 |
|
85 | 84 | /*
|
86 |
| - * Forces a directory scan in pgarch_readyXlog(). Protected by arch_lck. |
| 85 | + * Forces a directory scan in pgarch_readyXlog(). |
87 | 86 | */
|
88 |
| - bool force_dir_scan; |
89 |
| - |
90 |
| - slock_t arch_lck; |
| 87 | + pg_atomic_uint32 force_dir_scan; |
91 | 88 | } PgArchData;
|
92 | 89 |
|
93 | 90 | char *XLogArchiveLibrary = "";
|
@@ -174,7 +171,7 @@ PgArchShmemInit(void)
|
174 | 171 | /* First time through, so initialize */
|
175 | 172 | MemSet(PgArch, 0, PgArchShmemSize());
|
176 | 173 | PgArch->pgprocno = INVALID_PGPROCNO;
|
177 |
| - SpinLockInit(&PgArch->arch_lck); |
| 174 | + pg_atomic_init_u32(&PgArch->force_dir_scan, 0); |
178 | 175 | }
|
179 | 176 | }
|
180 | 177 |
|
@@ -545,18 +542,12 @@ pgarch_readyXlog(char *xlog)
|
545 | 542 | char XLogArchiveStatusDir[MAXPGPATH];
|
546 | 543 | DIR *rldir;
|
547 | 544 | struct dirent *rlde;
|
548 |
| - bool force_dir_scan; |
549 | 545 |
|
550 | 546 | /*
|
551 | 547 | * If a directory scan was requested, clear the stored file names and
|
552 | 548 | * proceed.
|
553 | 549 | */
|
554 |
| - SpinLockAcquire(&PgArch->arch_lck); |
555 |
| - force_dir_scan = PgArch->force_dir_scan; |
556 |
| - PgArch->force_dir_scan = false; |
557 |
| - SpinLockRelease(&PgArch->arch_lck); |
558 |
| - |
559 |
| - if (force_dir_scan) |
| 550 | + if (pg_atomic_exchange_u32(&PgArch->force_dir_scan, 0) == 1) |
560 | 551 | arch_files->arch_files_size = 0;
|
561 | 552 |
|
562 | 553 | /*
|
@@ -707,9 +698,7 @@ ready_file_comparator(Datum a, Datum b, void *arg)
|
707 | 698 | void
|
708 | 699 | PgArchForceDirScan(void)
|
709 | 700 | {
|
710 |
| - SpinLockAcquire(&PgArch->arch_lck); |
711 |
| - PgArch->force_dir_scan = true; |
712 |
| - SpinLockRelease(&PgArch->arch_lck); |
| 701 | + pg_atomic_write_membarrier_u32(&PgArch->force_dir_scan, 1); |
713 | 702 | }
|
714 | 703 |
|
715 | 704 | /*
|
|
0 commit comments