Skip to content
Snippets Groups Projects
Commit 7d904b2a authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Kirill Yukhin
Browse files

replication: merge replica_by_id into replicaset


For some reason the replica_by_id member (which is an
array of pointers) is allocated dynamically. Moreover
VCLOCK_MAX = 32 by now and extending it to some new
limit will require a way more efforts than just increase
the number.

Thus reserve memory for replica_by_id inside replicaset
statically. This allows to simplify code a bit and
drop calloc/free calls.

The former code comes from edd76a2a without any
explanation why the dynamic member is needed.

Acked-by: default avatarKonstantin Osipov <kostja.osipov@gmail.com>
Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 26645974
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,6 @@ replication_init(void)
rlist_create(&replicaset.anon);
vclock_create(&replicaset.vclock);
fiber_cond_create(&replicaset.applier.cond);
replicaset.replica_by_id = (struct replica **)calloc(VCLOCK_MAX, sizeof(struct replica *));
latch_create(&replicaset.applier.order_latch);
vclock_create(&replicaset.applier.vclock);
......@@ -112,7 +111,6 @@ replication_free(void)
relay_cancel(replica->relay);
diag_destroy(&replicaset.applier.diag);
free(replicaset.replica_by_id);
}
int
......
......@@ -251,7 +251,7 @@ struct replicaset {
struct diag diag;
} applier;
/** Map of all known replica_id's to correspponding replica's. */
struct replica **replica_by_id;
struct replica *replica_by_id[VCLOCK_MAX];
};
extern struct replicaset replicaset;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment