Skip to content

Commit 5ebbed7

Browse files
committed
relay: rename vclock args and make const
It wasn't clear which of them are inputs and which are outputs. The patch explicitly marks the input vclocks as const. It makes the code a bit easier to read inside of relay.cc knowing that these vclocks shouldn't change. Alongside "replica_clock" in subscribe is renamed to "start_vclock". To make it consistent with relay_final_join(), and to signify that technically it doesn't have to be a replica vclock. It isn't really. Box.cc alters the replica's vclock before giving it to relay, which means it is no longer "replica clock". In scope of tarantool#10047 NO_TEST=refactoring NO_CHANGELOG=refactoring NO_DOC=refactoring
1 parent 4dc0c1e commit 5ebbed7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/box/relay.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ relay_final_join_f(va_list ap)
532532

533533
void
534534
relay_final_join(struct replica *replica, struct iostream *io, uint64_t sync,
535-
struct vclock *start_vclock, struct vclock *stop_vclock)
535+
const struct vclock *start_vclock,
536+
const struct vclock *stop_vclock)
536537
{
537538
/*
538539
* As a new thread is started for the final join stage, its cancellation
@@ -1092,7 +1093,7 @@ relay_subscribe_f(va_list ap)
10921093
/** Replication acceptor fiber handler. */
10931094
void
10941095
relay_subscribe(struct replica *replica, struct iostream *io, uint64_t sync,
1095-
struct vclock *replica_clock, uint32_t replica_version_id,
1096+
const struct vclock *start_vclock, uint32_t replica_version_id,
10961097
uint32_t replica_id_filter, uint64_t sent_raft_term)
10971098
{
10981099
assert(replica->anon || replica->id != REPLICA_ID_NIL);
@@ -1112,9 +1113,9 @@ relay_subscribe(struct replica *replica, struct iostream *io, uint64_t sync,
11121113
/*
11131114
* Save the first vclock as 'received'. Because it was really received.
11141115
*/
1115-
vclock_copy(&relay->last_recv_ack.vclock, replica_clock);
1116-
relay->r = recovery_new(wal_dir(), false, replica_clock);
1117-
vclock_copy(&relay->tx.vclock, replica_clock);
1116+
vclock_copy(&relay->last_recv_ack.vclock, start_vclock);
1117+
relay->r = recovery_new(wal_dir(), false, start_vclock);
1118+
vclock_copy(&relay->tx.vclock, start_vclock);
11181119
relay->version_id = replica_version_id;
11191120

11201121
relay->id_filter |= replica_id_filter;

src/box/relay.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ relay_initial_join(struct iostream *io, uint64_t sync, struct vclock *vclock,
135135
*/
136136
void
137137
relay_final_join(struct replica *replica, struct iostream *io, uint64_t sync,
138-
struct vclock *start_vclock, struct vclock *stop_vclock);
138+
const struct vclock *start_vclock,
139+
const struct vclock *stop_vclock);
139140

140141
/**
141142
* Subscribe a replica to updates.
@@ -144,7 +145,7 @@ relay_final_join(struct replica *replica, struct iostream *io, uint64_t sync,
144145
*/
145146
void
146147
relay_subscribe(struct replica *replica, struct iostream *io, uint64_t sync,
147-
struct vclock *replica_vclock, uint32_t replica_version_id,
148+
const struct vclock *start_vclock, uint32_t replica_version_id,
148149
uint32_t replica_id_filter, uint64_t sent_raft_term);
149150

150151
#endif /* TARANTOOL_REPLICATION_RELAY_H_INCLUDED */

0 commit comments

Comments
 (0)