From abc75c3d3374e46481916e79709830a53bf761aa Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja.osipov@gmail.com>
Date: Mon, 11 Jul 2011 15:21:48 +0400
Subject: [PATCH] feature-feeder-in-core: review fixes

Rename hot_standby back to local_hot_standby. Let's
not break compatibility without a strong need.

Merge replication_source_ipaddr and replication_source_port
to a single variable, replication_source, to be able to
provide a list of sources in future.
---
 cfg/tarantool_box_cfg.c                       | 105 ++++++------------
 cfg/tarantool_box_cfg.cfg                     |  19 ++--
 cfg/tarantool_box_cfg.h                       |  19 ++--
 core/fiber.m                                  |  17 ++-
 core/log_io_remote.m                          |  16 ++-
 core/replication.m                            |   2 +-
 include/log_io.h                              |   3 +-
 mod/box/box.m                                 |  49 ++++----
 mod/box/box_cfg.cfg_tmpl                      |  20 ++--
 test/box/show.result                          |   5 +-
 .../box_replication/cfg/master_to_replica.cfg |   3 +-
 test/box_replication/cfg/replica.cfg          |   3 +-
 12 files changed, 112 insertions(+), 149 deletions(-)

diff --git a/cfg/tarantool_box_cfg.c b/cfg/tarantool_box_cfg.c
index 5bd8a1c829..4e4d564a1f 100644
--- a/cfg/tarantool_box_cfg.c
+++ b/cfg/tarantool_box_cfg.c
@@ -59,12 +59,11 @@ init_tarantool_cfg(tarantool_cfg *c) {
 	c->rows_per_wal = 0;
 	c->wal_fsync_delay = 0;
 	c->wal_writer_inbox_size = 0;
-	c->hot_standby = 0;
+	c->local_hot_standby = 0;
 	c->wal_dir_rescan_delay = 0;
 	c->panic_on_snap_error = 0;
 	c->panic_on_wal_error = 0;
-	c->replication_source_ipaddr = NULL;
-	c->replication_source_port = 0;
+	c->replication_source = NULL;
 	c->namespace = NULL;
 }
 
@@ -107,12 +106,11 @@ fill_default_tarantool_cfg(tarantool_cfg *c) {
 	c->rows_per_wal = 500000;
 	c->wal_fsync_delay = 0;
 	c->wal_writer_inbox_size = 128;
-	c->hot_standby = 0;
+	c->local_hot_standby = 0;
 	c->wal_dir_rescan_delay = 0.1;
 	c->panic_on_snap_error = 1;
 	c->panic_on_wal_error = 0;
-	c->replication_source_ipaddr = NULL;
-	c->replication_source_port = 0;
+	c->replication_source = NULL;
 	c->namespace = NULL;
 	return 0;
 }
@@ -243,8 +241,8 @@ static NameAtom _name__wal_fsync_delay[] = {
 static NameAtom _name__wal_writer_inbox_size[] = {
 	{ "wal_writer_inbox_size", -1, NULL }
 };
-static NameAtom _name__hot_standby[] = {
-	{ "hot_standby", -1, NULL }
+static NameAtom _name__local_hot_standby[] = {
+	{ "local_hot_standby", -1, NULL }
 };
 static NameAtom _name__wal_dir_rescan_delay[] = {
 	{ "wal_dir_rescan_delay", -1, NULL }
@@ -255,11 +253,8 @@ static NameAtom _name__panic_on_snap_error[] = {
 static NameAtom _name__panic_on_wal_error[] = {
 	{ "panic_on_wal_error", -1, NULL }
 };
-static NameAtom _name__replication_source_ipaddr[] = {
-	{ "replication_source_ipaddr", -1, NULL }
-};
-static NameAtom _name__replication_source_port[] = {
-	{ "replication_source_port", -1, NULL }
+static NameAtom _name__replication_source[] = {
+	{ "replication_source", -1, NULL }
 };
 static NameAtom _name__namespace[] = {
 	{ "namespace", -1, NULL }
@@ -729,7 +724,7 @@ acceptValue(tarantool_cfg* c, OptDef* opt, int check_rdonly) {
 			return CNF_RDONLY;
 		c->wal_writer_inbox_size = i32;
 	}
-	else if ( cmpNameAtoms( opt->name, _name__hot_standby) ) {
+	else if ( cmpNameAtoms( opt->name, _name__local_hot_standby) ) {
 		if (opt->paramType != numberType )
 			return CNF_WRONGTYPE;
 		c->__confetti_flags &= ~CNF_FLAG_STRUCT_NOTSET;
@@ -739,9 +734,9 @@ acceptValue(tarantool_cfg* c, OptDef* opt, int check_rdonly) {
 			return CNF_WRONGINT;
 		if ( (i32 == LONG_MIN || i32 == LONG_MAX) && errno == ERANGE)
 			return CNF_WRONGRANGE;
-		if (check_rdonly && c->hot_standby != i32)
+		if (check_rdonly && c->local_hot_standby != i32)
 			return CNF_RDONLY;
-		c->hot_standby = i32;
+		c->local_hot_standby = i32;
 	}
 	else if ( cmpNameAtoms( opt->name, _name__wal_dir_rescan_delay) ) {
 		if (opt->paramType != numberType )
@@ -783,27 +778,15 @@ acceptValue(tarantool_cfg* c, OptDef* opt, int check_rdonly) {
 			return CNF_RDONLY;
 		c->panic_on_wal_error = i32;
 	}
-	else if ( cmpNameAtoms( opt->name, _name__replication_source_ipaddr) ) {
+	else if ( cmpNameAtoms( opt->name, _name__replication_source) ) {
 		if (opt->paramType != stringType )
 			return CNF_WRONGTYPE;
 		c->__confetti_flags &= ~CNF_FLAG_STRUCT_NOTSET;
 		errno = 0;
-		c->replication_source_ipaddr = (opt->paramValue.stringval) ? strdup(opt->paramValue.stringval) : NULL;
-		if (opt->paramValue.stringval && c->replication_source_ipaddr == NULL)
+		c->replication_source = (opt->paramValue.stringval) ? strdup(opt->paramValue.stringval) : NULL;
+		if (opt->paramValue.stringval && c->replication_source == NULL)
 			return CNF_NOMEMORY;
 	}
-	else if ( cmpNameAtoms( opt->name, _name__replication_source_port) ) {
-		if (opt->paramType != numberType )
-			return CNF_WRONGTYPE;
-		c->__confetti_flags &= ~CNF_FLAG_STRUCT_NOTSET;
-		errno = 0;
-		long int i32 = strtol(opt->paramValue.numberval, NULL, 10);
-		if (i32 == 0 && errno == EINVAL)
-			return CNF_WRONGINT;
-		if ( (i32 == LONG_MIN || i32 == LONG_MAX) && errno == ERANGE)
-			return CNF_WRONGRANGE;
-		c->replication_source_port = i32;
-	}
 	else if ( cmpNameAtoms( opt->name, _name__namespace) ) {
 		if (opt->paramType != arrayType )
 			return CNF_WRONGTYPE;
@@ -1111,12 +1094,11 @@ typedef enum IteratorState {
 	S_name__rows_per_wal,
 	S_name__wal_fsync_delay,
 	S_name__wal_writer_inbox_size,
-	S_name__hot_standby,
+	S_name__local_hot_standby,
 	S_name__wal_dir_rescan_delay,
 	S_name__panic_on_snap_error,
 	S_name__panic_on_wal_error,
-	S_name__replication_source_ipaddr,
-	S_name__replication_source_port,
+	S_name__replication_source,
 	S_name__namespace,
 	S_name__namespace__enabled,
 	S_name__namespace__cardinality,
@@ -1485,17 +1467,17 @@ tarantool_cfg_iterator_next(tarantool_cfg_iterator_t* i, tarantool_cfg *c, char
 			}
 			sprintf(*v, "%"PRId32, c->wal_writer_inbox_size);
 			snprintf(buf, PRINTBUFLEN-1, "wal_writer_inbox_size");
-			i->state = S_name__hot_standby;
+			i->state = S_name__local_hot_standby;
 			return buf;
-		case S_name__hot_standby:
+		case S_name__local_hot_standby:
 			*v = malloc(32);
 			if (*v == NULL) {
 				free(i);
 				out_warning(CNF_NOMEMORY, "No memory to output value");
 				return NULL;
 			}
-			sprintf(*v, "%"PRId32, c->hot_standby);
-			snprintf(buf, PRINTBUFLEN-1, "hot_standby");
+			sprintf(*v, "%"PRId32, c->local_hot_standby);
+			snprintf(buf, PRINTBUFLEN-1, "local_hot_standby");
 			i->state = S_name__wal_dir_rescan_delay;
 			return buf;
 		case S_name__wal_dir_rescan_delay:
@@ -1529,27 +1511,16 @@ tarantool_cfg_iterator_next(tarantool_cfg_iterator_t* i, tarantool_cfg *c, char
 			}
 			sprintf(*v, "%"PRId32, c->panic_on_wal_error);
 			snprintf(buf, PRINTBUFLEN-1, "panic_on_wal_error");
-			i->state = S_name__replication_source_ipaddr;
+			i->state = S_name__replication_source;
 			return buf;
-		case S_name__replication_source_ipaddr:
-			*v = (c->replication_source_ipaddr) ? strdup(c->replication_source_ipaddr) : NULL;
-			if (*v == NULL && c->replication_source_ipaddr) {
+		case S_name__replication_source:
+			*v = (c->replication_source) ? strdup(c->replication_source) : NULL;
+			if (*v == NULL && c->replication_source) {
 				free(i);
 				out_warning(CNF_NOMEMORY, "No memory to output value");
 				return NULL;
 			}
-			snprintf(buf, PRINTBUFLEN-1, "replication_source_ipaddr");
-			i->state = S_name__replication_source_port;
-			return buf;
-		case S_name__replication_source_port:
-			*v = malloc(32);
-			if (*v == NULL) {
-				free(i);
-				out_warning(CNF_NOMEMORY, "No memory to output value");
-				return NULL;
-			}
-			sprintf(*v, "%"PRId32, c->replication_source_port);
-			snprintf(buf, PRINTBUFLEN-1, "replication_source_port");
+			snprintf(buf, PRINTBUFLEN-1, "replication_source");
 			i->state = S_name__namespace;
 			return buf;
 		case S_name__namespace:
@@ -1879,14 +1850,13 @@ dup_tarantool_cfg(tarantool_cfg* dst, tarantool_cfg* src) {
 	dst->rows_per_wal = src->rows_per_wal;
 	dst->wal_fsync_delay = src->wal_fsync_delay;
 	dst->wal_writer_inbox_size = src->wal_writer_inbox_size;
-	dst->hot_standby = src->hot_standby;
+	dst->local_hot_standby = src->local_hot_standby;
 	dst->wal_dir_rescan_delay = src->wal_dir_rescan_delay;
 	dst->panic_on_snap_error = src->panic_on_snap_error;
 	dst->panic_on_wal_error = src->panic_on_wal_error;
-	dst->replication_source_ipaddr = src->replication_source_ipaddr == NULL ? NULL : strdup(src->replication_source_ipaddr);
-	if (src->replication_source_ipaddr != NULL && dst->replication_source_ipaddr == NULL)
+	dst->replication_source = src->replication_source == NULL ? NULL : strdup(src->replication_source);
+	if (src->replication_source != NULL && dst->replication_source == NULL)
 		return CNF_NOMEMORY;
-	dst->replication_source_port = src->replication_source_port;
 
 	dst->namespace = NULL;
 	if (src->namespace != NULL) {
@@ -1963,8 +1933,8 @@ destroy_tarantool_cfg(tarantool_cfg* c) {
 		free(c->wal_dir);
 	if (c->custom_proc_title != NULL)
 		free(c->custom_proc_title);
-	if (c->replication_source_ipaddr != NULL)
-		free(c->replication_source_ipaddr);
+	if (c->replication_source != NULL)
+		free(c->replication_source);
 
 	if (c->namespace != NULL) {
 		i->idx_name__namespace = 0;
@@ -2191,8 +2161,8 @@ cmp_tarantool_cfg(tarantool_cfg* c1, tarantool_cfg* c2, int only_check_rdonly) {
 
 		return diff;
 	}
-	if (c1->hot_standby != c2->hot_standby) {
-		snprintf(diff, PRINTBUFLEN - 1, "%s", "c->hot_standby");
+	if (c1->local_hot_standby != c2->local_hot_standby) {
+		snprintf(diff, PRINTBUFLEN - 1, "%s", "c->local_hot_standby");
 
 		return diff;
 	}
@@ -2212,19 +2182,12 @@ cmp_tarantool_cfg(tarantool_cfg* c1, tarantool_cfg* c2, int only_check_rdonly) {
 		return diff;
 	}
 	if (!only_check_rdonly) {
-		if (confetti_strcmp(c1->replication_source_ipaddr, c2->replication_source_ipaddr) != 0) {
-			snprintf(diff, PRINTBUFLEN - 1, "%s", "c->replication_source_ipaddr");
+		if (confetti_strcmp(c1->replication_source, c2->replication_source) != 0) {
+			snprintf(diff, PRINTBUFLEN - 1, "%s", "c->replication_source");
 
 			return diff;
 }
 	}
-	if (!only_check_rdonly) {
-		if (c1->replication_source_port != c2->replication_source_port) {
-			snprintf(diff, PRINTBUFLEN - 1, "%s", "c->replication_source_port");
-
-			return diff;
-		}
-	}
 
 	i1->idx_name__namespace = 0;
 	i2->idx_name__namespace = 0;
diff --git a/cfg/tarantool_box_cfg.cfg b/cfg/tarantool_box_cfg.cfg
index 28a534e676..3b2e6f8435 100644
--- a/cfg/tarantool_box_cfg.cfg
+++ b/cfg/tarantool_box_cfg.cfg
@@ -102,9 +102,11 @@ wal_fsync_delay = 0
 # size of WAL writer request buffer
 wal_writer_inbox_size = 128
 
-# Hot standby (if enabled, the server will run in hot standby
-# mode, continuously fetching WAL records from shared directory).
-hot_standby = 0
+# Local hot standby (if enabled, the server will run in hot
+# standby mode, continuously fetching WAL records from wal_dir,
+# until it is able to bind to the primary port.
+# In local hot standby mode the server only accepts reads.
+local_hot_standby = 0
 
 # Delay, in seconds, between successive re-readings of wal_dir.
 # The re-scan is necessary to discover new WAL files or snapshots.
@@ -116,11 +118,12 @@ wal_dir_rescan_delay = 0.1
 panic_on_snap_error = 1
 panic_on_wal_error = 0
 
-# Replicator mode (if enabled, the server will run in replication mode
-# continuously fetching WAL records from
-# replication_source_ipaddr:replication_source_port
-replication_source_ipaddr = NULL
-replication_source_port = 0
+# Replication mode (if enabled, the server, once
+# bound to the primary port, will connect to
+# replication_source (ipaddr:port) and run continously
+# fetching records from it.. In replication mode the server
+# only accepts reads.
+replication_source = NULL
 namespace = [    {
         enabled = -1
         cardinality = -1
diff --git a/cfg/tarantool_box_cfg.h b/cfg/tarantool_box_cfg.h
index 4bca0ad8c4..eda7d13bfc 100644
--- a/cfg/tarantool_box_cfg.h
+++ b/cfg/tarantool_box_cfg.h
@@ -154,10 +154,12 @@ typedef struct tarantool_cfg {
 	int32_t	wal_writer_inbox_size;
 
 	/*
-	 * Hot standby (if enabled, the server will run in hot standby
-	 * mode, continuously fetching WAL records from shared directory).
+	 * Local hot standby (if enabled, the server will run in hot
+	 * standby mode, continuously fetching WAL records from wal_dir,
+	 * until it is able to bind to the primary port.
+	 * In local hot standby mode the server only accepts reads.
 	 */
-	int32_t	hot_standby;
+	int32_t	local_hot_standby;
 
 	/*
 	 * Delay, in seconds, between successive re-readings of wal_dir.
@@ -174,12 +176,13 @@ typedef struct tarantool_cfg {
 	int32_t	panic_on_wal_error;
 
 	/*
-	 * Replicator mode (if enabled, the server will run in replication mode
-	 * continuously fetching WAL records from
-	 * replication_source_ipaddr:replication_source_port
+	 * Replication mode (if enabled, the server, once
+	 * bound to the primary port, will connect to
+	 * replication_source (ipaddr:port) and run continously
+	 * fetching records from it.. In replication mode the server
+	 * only accepts reads.
 	 */
-	char*	replication_source_ipaddr;
-	int32_t	replication_source_port;
+	char*	replication_source;
 	tarantool_cfg_namespace**	namespace;
 } tarantool_cfg;
 
diff --git a/core/fiber.m b/core/fiber.m
index 65ab6be358..6557156e1e 100644
--- a/core/fiber.m
+++ b/core/fiber.m
@@ -490,7 +490,7 @@ fiber_create(const char *name, int fd, int inbox_size, void (*f) (void *), void
 		if (tarantool_coro_create(&fiber->coro, fiber_loop, NULL) == NULL)
 			return NULL;
 
-		fiber->pool = palloc_create_pool(name);
+		fiber->pool = palloc_create_pool("");
 		fiber->inbox = palloc(eter_pool, (sizeof(*fiber->inbox) +
 						  inbox_size * sizeof(struct tbuf *)));
 		fiber->inbox->size = inbox_size;
@@ -1029,7 +1029,7 @@ struct child *
 spawn_child(const char *name, int inbox_size, struct tbuf *(*handler) (void *, struct tbuf *),
 	    void *state)
 {
-	char *proxy_name;
+	char proxy_name[FIBER_NAME_MAXLEN];
 	int socks[2];
 	int pid;
 
@@ -1051,12 +1051,10 @@ spawn_child(const char *name, int inbox_size, struct tbuf *(*handler) (void *, s
 		struct child *c = palloc(eter_pool, sizeof(*c));
 		c->pid = pid;
 
-		proxy_name = palloc(eter_pool, 64);
-		snprintf(proxy_name, 64, "%s/sock2inbox", name);
+		snprintf(proxy_name, sizeof(proxy_name), "%s/sock2inbox", name);
 		c->in = fiber_create(proxy_name, socks[1], inbox_size, sock2inbox, NULL);
 		fiber_call(c->in);
-		proxy_name = palloc(eter_pool, 64);
-		snprintf(proxy_name, 64, "%s/inbox2sock", name);
+		snprintf(proxy_name, sizeof(proxy_name), "%s/inbox2sock", name);
 		c->out = fiber_create(proxy_name, socks[1], inbox_size, inbox2sock, NULL);
 		c->out->flags |= FIBER_READING_INBOX;
 		return c;
@@ -1082,7 +1080,7 @@ tcp_server_handler(void *data)
 {
 	struct fiber_server *server = fiber->data;
 	struct fiber *h;
-	char name[64];
+	char name[FIBER_NAME_MAXLEN];
 	int fd;
 	int one = 1;
 
@@ -1134,12 +1132,11 @@ struct fiber *
 fiber_server(int port, void (*handler) (void *data), void *data,
 	     void (*on_bind) (void *data))
 {
-	char *server_name;
+	char server_name[FIBER_NAME_MAXLEN];
 	struct fiber_server *server;
 	struct fiber *s;
 
-	server_name = palloc(eter_pool, 64);
-	snprintf(server_name, 64, "%i/acceptor", port);
+	snprintf(server_name, sizeof(server_name), "%i/acceptor", port);
 	s = fiber_create(server_name, -1, -1, tcp_server_handler, data);
 	s->data = server = palloc(eter_pool, sizeof(struct fiber_server));
 	assert(server != NULL);
diff --git a/core/log_io_remote.m b/core/log_io_remote.m
index 5f44a37251..9750a7485c 100644
--- a/core/log_io_remote.m
+++ b/core/log_io_remote.m
@@ -178,10 +178,12 @@ default_remote_row_handler(struct recovery_state *r, struct tbuf *row)
 }
 
 void
-recovery_follow_remote(struct recovery_state *r,
-		       const char *ip_addr, int port)
+recovery_follow_remote(struct recovery_state *r, const char *remote)
 {
-	char *name;
+	char name[FIBER_NAME_MAXLEN];
+	char ip_addr[32];
+	int port;
+	int rc;
 	struct fiber *f;
 	struct in_addr server;
 	struct sockaddr_in *addr;
@@ -189,9 +191,8 @@ recovery_follow_remote(struct recovery_state *r,
 
 	assert(r->remote_recovery == NULL);
 
-	say_crit("initializing the replica, WAL master %s:%i", ip_addr, port);
-	name = palloc(eter_pool, 64);
-	snprintf(name, 64, "replica/%s:%i", ip_addr, port);
+	say_crit("initializing the replica, WAL master %s", remote);
+	snprintf(name, sizeof(name), "replica/%s", remote);
 
 	h = palloc(eter_pool, sizeof(*h));
 	h->r = r;
@@ -201,6 +202,9 @@ recovery_follow_remote(struct recovery_state *r,
 	if (f == NULL)
 		return;
 
+	rc = sscanf(remote, "%31[^:]:%i", ip_addr, &port);
+	assert(rc == 2);
+
 	if (inet_aton(ip_addr, &server) < 0) {
 		say_syserror("inet_aton: %s", ip_addr);
 		return;
diff --git a/core/replication.m b/core/replication.m
index 100da89d74..dd0ca5d65a 100644
--- a/core/replication.m
+++ b/core/replication.m
@@ -642,7 +642,7 @@ spawner_shutdown_wait_children()
 static void
 replication_relay_loop(int client_sock)
 {
-	char name[sizeof(fiber->name)];
+	char name[FIBER_NAME_MAXLEN];
 	struct sigaction sa;
 	struct recovery_state *log_io;
 	struct tbuf *ver;
diff --git a/include/log_io.h b/include/log_io.h
index 1b3214ac91..9a55535407 100644
--- a/include/log_io.h
+++ b/include/log_io.h
@@ -169,8 +169,7 @@ void recovery_wait_lsn(struct recovery_state *r, i64 lsn);
 int read_log(const char *filename,
 	     row_handler xlog_handler, row_handler snap_handler, void *state);
 
-void recovery_follow_remote(struct recovery_state *r,
-			    const char *ip_addr, int port);
+void recovery_follow_remote(struct recovery_state *r, const char *remote);
 void recovery_stop_remote(struct recovery_state *r);
 
 struct log_io_iter;
diff --git a/mod/box/box.m b/mod/box/box.m
index a167b7023a..ff8f9e1568 100644
--- a/mod/box/box.m
+++ b/mod/box/box.m
@@ -1184,20 +1184,15 @@ title(const char *fmt, ...)
 static void
 box_enter_master_or_replica_mode(struct tarantool_cfg *conf)
 {
-	if (conf->replication_source_port != 0) {
+	if (conf->replication_source != NULL) {
 		rw_callback = box_process_ro;
 
 		recovery_wait_lsn(recovery_state, recovery_state->lsn);
-		recovery_follow_remote(recovery_state,
-				       conf->replication_source_ipaddr,
-				       conf->replication_source_port);
-
-		snprintf(status, sizeof(status), "replica/%s:%i%s",
-			 conf->replication_source_ipaddr,
-			 conf->replication_source_port,
-			 custom_proc_title);
-		title("replica/%s:%i%s", conf->replication_source_ipaddr,
-		      conf->replication_source_port, custom_proc_title);
+		recovery_follow_remote(recovery_state, conf->replication_source);
+
+		snprintf(status, sizeof(status), "replica/%s%s",
+			 conf->replication_source, custom_proc_title);
+		title("replica/%s%s", conf->replication_source, custom_proc_title);
 	} else {
 		rw_callback = box_process_rw;
 
@@ -1222,23 +1217,25 @@ i32
 mod_check_config(struct tarantool_cfg *conf)
 {
 	/* replication & hot standby modes can not work together */
-	if (conf->replication_source_port != 0 && conf->hot_standby > 0) {
-		out_warning(0, "replication and hot standby modes "
+	if (conf->replication_source != NULL && conf->local_hot_standby > 0) {
+		out_warning(0, "replication and local hot standby modes "
 			       "can't be enabled simultaneously");
 		return -1;
 	}
 
 	/* check replication mode */
-	if (conf->replication_source_port != 0) {
+	if (conf->replication_source != NULL) {
 		/* check replication port */
-		if (conf->replication_source_port <= 0 || conf->replication_source_port >= USHRT_MAX) {
-			out_warning(0, "invalid replication_source_port value: %i", conf->replication_source_port);
+		char ip_addr[32];
+		int port;
+
+		if (sscanf(conf->replication_source, "%31[^:]:%i",
+			   ip_addr, &port) != 2) {
+			out_warning(0, "replication source IP address is not recognized");
 			return -1;
 		}
-
-		/* in the replication mode replication_source_ipaddr must be specified */
-		if (conf->replication_source_ipaddr == NULL) {
-			out_warning(0, "replication_source_ipaddr must be provided in replication mode");
+		if (port <= 0 || port >= USHRT_MAX) {
+			out_warning(0, "invalid replication source port value: %i", port);
 			return -1;
 		}
 	}
@@ -1396,13 +1393,12 @@ mod_check_config(struct tarantool_cfg *conf)
 i32
 mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf)
 {
-	bool old_is_replica = old_conf->replication_source_port != 0;
-	bool new_is_replica = new_conf->replication_source_port != 0;
+	bool old_is_replica = old_conf->replication_source != NULL;
+	bool new_is_replica = new_conf->replication_source != NULL;
 
 	if (old_is_replica != new_is_replica ||
 	    (old_is_replica &&
-	     (strcmp(old_conf->replication_source_ipaddr, new_conf->replication_source_ipaddr) != 0 ||
-	      old_conf->replication_source_port != new_conf->replication_source_port))) {
+	     (strcmp(old_conf->replication_source, new_conf->replication_source) != 0))) {
 
 		if (recovery_state->finalize != true) {
 			out_warning(0, "Could not propagate %s before local recovery finished",
@@ -1412,8 +1408,7 @@ mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf
 			return -1;
 		}
 
-		if (old_conf->replication_source_port == 0 &&
-		    new_conf->replication_source_port != 0)
+		if (!old_is_replica && new_is_replica)
 			memcached_stop_expire();
 
 		if (recovery_state->remote_recovery)
@@ -1462,7 +1457,7 @@ mod_init(void)
 
 	title("orphan");
 
-	if (cfg.hot_standby) {
+	if (cfg.local_hot_standby) {
 		say_info("starting local hot standby");
 		recover_follow(recovery_state, cfg.wal_dir_rescan_delay);
 		snprintf(status, sizeof(status), "hot_standby");
diff --git a/mod/box/box_cfg.cfg_tmpl b/mod/box/box_cfg.cfg_tmpl
index 3915371bcf..b2592128c8 100644
--- a/mod/box/box_cfg.cfg_tmpl
+++ b/mod/box/box_cfg.cfg_tmpl
@@ -45,9 +45,11 @@ wal_fsync_delay=0, ro
 # size of WAL writer request buffer
 wal_writer_inbox_size=128, ro
 
-# Hot standby (if enabled, the server will run in hot standby
-# mode, continuously fetching WAL records from shared directory).
-hot_standby=0, ro
+# Local hot standby (if enabled, the server will run in hot
+# standby mode, continuously fetching WAL records from wal_dir,
+# until it is able to bind to the primary port.
+# In local hot standby mode the server only accepts reads.
+local_hot_standby=0, ro
 # Delay, in seconds, between successive re-readings of wal_dir.
 # The re-scan is necessary to discover new WAL files or snapshots.
 wal_dir_rescan_delay=0.1, ro
@@ -59,12 +61,12 @@ wal_dir_rescan_delay=0.1, ro
 panic_on_snap_error=1, ro
 panic_on_wal_error=0, ro
 
-# Replicator mode (if enabled, the server will run in replication mode
-# continuously fetching WAL records from
-# replication_source_ipaddr:replication_source_port
-replication_source_ipaddr=NULL
-replication_source_port=0
-
+# Replication mode (if enabled, the server, once
+# bound to the primary port, will connect to
+# replication_source (ipaddr:port) and run continously
+# fetching records from it.. In replication mode the server
+# only accepts reads.
+replication_source=NULL
 
 namespace = [
   {
diff --git a/test/box/show.result b/test/box/show.result
index 870a8d416f..6c8d92cf83 100644
--- a/test/box/show.result
+++ b/test/box/show.result
@@ -57,12 +57,11 @@ configuration:
   rows_per_wal: "50"
   wal_fsync_delay: "0"
   wal_writer_inbox_size: "128"
-  hot_standby: "0"
+  local_hot_standby: "0"
   wal_dir_rescan_delay: "0.1"
   panic_on_snap_error: "1"
   panic_on_wal_error: "0"
-  replication_source_ipaddr: (null)
-  replication_source_port: "0"
+  replication_source: (null)
   namespace[0].enabled: "1"
   namespace[0].cardinality: "-1"
   namespace[0].estimated_rows: "0"
diff --git a/test/box_replication/cfg/master_to_replica.cfg b/test/box_replication/cfg/master_to_replica.cfg
index d19f749674..172daaca51 100644
--- a/test/box_replication/cfg/master_to_replica.cfg
+++ b/test/box_replication/cfg/master_to_replica.cfg
@@ -16,5 +16,4 @@ namespace[0].index[0].unique = 1
 namespace[0].index[0].key_field[0].fieldno = 0
 namespace[0].index[0].key_field[0].type = "NUM"
 
-replication_source_ipaddr = "127.0.0.1"
-replication_source_port = 33116
+replication_source = "127.0.0.1:33116"
diff --git a/test/box_replication/cfg/replica.cfg b/test/box_replication/cfg/replica.cfg
index 5db5788c82..a3d5898b04 100644
--- a/test/box_replication/cfg/replica.cfg
+++ b/test/box_replication/cfg/replica.cfg
@@ -16,5 +16,4 @@ namespace[0].index[0].unique = 1
 namespace[0].index[0].key_field[0].fieldno = 0
 namespace[0].index[0].key_field[0].type = "NUM"
 
-replication_source_ipaddr = "127.0.0.1"
-replication_source_port = 33016
+replication_source = "127.0.0.1:33016"
-- 
GitLab