0002-Change-WalSndWakeupProcessRequests-and-WalSndWakeupR.patch
text/x-patch
Filename: 0002-Change-WalSndWakeupProcessRequests-and-WalSndWakeupR.patch
Type: text/x-patch
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0002
Subject: Change WalSndWakeupProcessRequests and WalSndWakeupRequest into macros
| File | + | − |
|---|---|---|
| src/backend/replication/walsender.c | 4 | 34 |
| src/include/replication/walsender.h | 25 | 2 |
From aafd463ae415d3ce06526d72dbd85e8a571c634a Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 27 Jun 2012 12:23:01 +0200
Subject: [PATCH 2/2] Change WalSndWakeupProcessRequests and
WalSndWakeupRequest into macros
---
src/backend/replication/walsender.c | 38 ++++-------------------------------
src/include/replication/walsender.h | 27 +++++++++++++++++++++++--
2 files changed, 29 insertions(+), 36 deletions(-)
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index fc3ffe1..a3ec1bc 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -81,6 +81,10 @@ bool am_cascading_walsender = false; /* Am I cascading WAL to
int max_wal_senders = 0; /* the maximum number of concurrent walsenders */
int replication_timeout = 60 * 1000; /* maximum time to send one
* WAL data message */
+/*
+ * State for WalSndWakeupRequest
+ */
+bool wroteNewXlogData = false;
/*
* These variables are used similarly to openLogFile/Id/Seg/Off,
@@ -106,11 +110,6 @@ static StringInfoData reply_message;
*/
static TimestampTz last_reply_timestamp;
-/*
- * State for WalSndWakeupRequest
- */
-static bool wroteNewXlogData = false;
-
/* Flags set by signal handlers for later service in main loop */
static volatile sig_atomic_t got_SIGHUP = false;
volatile sig_atomic_t walsender_shutdown_requested = false;
@@ -1415,35 +1414,6 @@ WalSndWakeup(void)
SetLatch(&WalSndCtl->walsnds[i].latch);
}
-/*
- * Remember that we want to wakeup walsenders later
- *
- * This is separated from doing the actual wakeup because the writeout is done
- * while holding contended locks.
- */
-void
-WalSndWakeupRequest(void)
-{
- wroteNewXlogData = true;
-}
-
-/*
- * wakeup walsenders if there is work to be done
- */
-void
-WalSndWakeupProcessRequests(void)
-{
- if(wroteNewXlogData){
- wroteNewXlogData = false;
- /*
- * Wake up all walsenders to send WAL up to the point where its flushed
- * safely to disk.
- */
- if (max_wal_senders > 0)
- WalSndWakeup();
- }
-}
-
/* Set state for current walsender (only called in walsender) */
void
WalSndSetState(WalSndState state)
diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h
index 483e77e..07ffa40 100644
--- a/src/include/replication/walsender.h
+++ b/src/include/replication/walsender.h
@@ -21,6 +21,7 @@ extern bool am_walsender;
extern bool am_cascading_walsender;
extern volatile sig_atomic_t walsender_shutdown_requested;
extern volatile sig_atomic_t walsender_ready_to_stop;
+extern bool wroteNewXlogData;
/* user-settable parameters */
extern int max_wal_senders;
@@ -31,10 +32,32 @@ extern void WalSndSignals(void);
extern Size WalSndShmemSize(void);
extern void WalSndShmemInit(void);
extern void WalSndWakeup(void);
-extern void WalSndWakeupRequest(void);
-extern void WalSndWakeupProcessRequests(void);
extern void WalSndRqstFileReload(void);
extern Datum pg_stat_get_wal_senders(PG_FUNCTION_ARGS);
+/*
+ * Remember that we want to wakeup walsenders later
+ *
+ * This is separated from doing the actual wakeup because the writeout is done
+ * while holding contended locks.
+ */
+#define WalSndWakeupRequest() do { wroteNewXlogData = true; } while(0)
+
+/*
+ * wakeup walsenders if there is work to be done
+ */
+#define WalSndWakeupProcessRequests() \
+do { \
+ if(wroteNewXlogData){ \
+ wroteNewXlogData = false; \
+ /* \
+ * Wake up all walsenders to send WAL up to the point where its \
+ * flushed safely to disk. \
+ */ \
+ if (max_wal_senders > 0) \
+ WalSndWakeup(); \
+ } \
+} while (0)
+
#endif /* _WALSENDER_H */
--
1.7.10.rc3.3.g19a6c.dirty