summaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/pg_receivexlog.c
diff options
context:
space:
mode:
authorMagnus Hagander2016-03-11 10:08:01 +0000
committerMagnus Hagander2016-03-11 10:15:12 +0000
commit38c83c9b7569378d864d8915e291716b8bec15f2 (patch)
tree1bd74adad635b071024708f90d591074bf125ec0 /src/bin/pg_basebackup/pg_receivexlog.c
parent73e7e49da3b23a15cd84f003e11ad7d55ad80da7 (diff)
Refactor receivelog.c parameters
Much cruft had accumulated over time with a large number of parameters passed down between functions very deep. With this refactoring, instead introduce a StreamCtl structure that holds the parameters, and pass around a pointer to this structure instead. This makes it much easier to add or remove fields that are needed deeper down in the implementation without having to modify every function header in the file. Patch by me after much nagging from Andres Reviewed by Craig Ringer and Daniel Gustafsson
Diffstat (limited to 'src/bin/pg_basebackup/pg_receivexlog.c')
-rw-r--r--src/bin/pg_basebackup/pg_receivexlog.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c
index f96b547b0f3..7f7ee9dc9ba 100644
--- a/src/bin/pg_basebackup/pg_receivexlog.c
+++ b/src/bin/pg_basebackup/pg_receivexlog.c
@@ -276,10 +276,11 @@ FindStreamingStart(uint32 *tli)
static void
StreamLog(void)
{
- XLogRecPtr startpos,
- serverpos;
- TimeLineID starttli,
- servertli;
+ XLogRecPtr serverpos;
+ TimeLineID servertli;
+ StreamCtl stream;
+
+ MemSet(&stream, 0, sizeof(stream));
/*
* Connect in replication mode to the server
@@ -311,17 +312,17 @@ StreamLog(void)
/*
* Figure out where to start streaming.
*/
- startpos = FindStreamingStart(&starttli);
- if (startpos == InvalidXLogRecPtr)
+ stream.startpos = FindStreamingStart(&stream.timeline);
+ if (stream.startpos == InvalidXLogRecPtr)
{
- startpos = serverpos;
- starttli = servertli;
+ stream.startpos = serverpos;
+ stream.timeline = servertli;
}
/*
* Always start streaming at the beginning of a segment
*/
- startpos -= startpos % XLOG_SEG_SIZE;
+ stream.startpos -= stream.startpos % XLOG_SEG_SIZE;
/*
* Start the replication
@@ -329,12 +330,17 @@ StreamLog(void)
if (verbose)
fprintf(stderr,
_("%s: starting log streaming at %X/%X (timeline %u)\n"),
- progname, (uint32) (startpos >> 32), (uint32) startpos,
- starttli);
+ progname, (uint32) (stream.startpos >> 32), (uint32) stream.startpos,
+ stream.timeline);
+
+ stream.stream_stop = stop_streaming;
+ stream.standby_message_timeout = standby_message_timeout;
+ stream.synchronous = synchronous;
+ stream.mark_done = false;
+ stream.basedir = basedir;
+ stream.partial_suffix = ".partial";
- ReceiveXlogStream(conn, startpos, starttli, NULL, basedir,
- stop_streaming, standby_message_timeout, ".partial",
- synchronous, false);
+ ReceiveXlogStream(conn, &stream);
PQfinish(conn);
conn = NULL;