Skip to content

Commit 780f610

Browse files
ing-eokingjhpark816
authored andcommitted
INTERNAL: Add an arcus_zk_initalized function
1 parent 65e3d22 commit 780f610

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

arcus_zk.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,11 @@ void arcus_zk_get_stats(arcus_zk_stats *stats)
18381838
#endif
18391839
}
18401840

1841+
bool arcus_zk_initalized(void)
1842+
{
1843+
return main_zk != NULL;
1844+
}
1845+
18411846
#ifdef ENABLE_CLUSTER_AWARE
18421847
int arcus_key_is_mine(const char *key, size_t nkey, bool *mine)
18431848
{

arcus_zk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ bool arcus_zk_get_failstop(void);
6161
void arcus_zk_get_confs(arcus_zk_confs *confs);
6262
void arcus_zk_get_stats(arcus_zk_stats *stats);
6363

64+
bool arcus_zk_initalized(void);
6465
#ifdef ENABLE_CLUSTER_AWARE
6566
int arcus_key_is_mine(const char *key, size_t nkey, bool *mine);
6667
#endif

memcached.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9246,7 +9246,7 @@ static void process_zkensemble_command(conn *c, token_t *tokens, const size_t nt
92469246
char *subcommand = tokens[SUBCOMMAND_TOKEN].value;
92479247
bool valid = false;
92489248

9249-
if (arcus_zk_cfg == NULL) {
9249+
if (!arcus_zk_initalized()) {
92509250
out_string(c, "ERROR not using ZooKeeper");
92519251
return;
92529252
}
@@ -13271,7 +13271,7 @@ static void process_command_ascii(conn *c, char *command, int cmdlen)
1327113271
{
1327213272
char *response = "READY";
1327313273
#ifdef ENABLE_ZK_INTEGRATION
13274-
if (arcus_zk_cfg) {
13274+
if (arcus_zk_initalized()) {
1327513275
arcus_zk_stats zk_stats;
1327613276
arcus_zk_get_stats(&zk_stats);
1327713277
if (!zk_stats.zk_ready) response = "NOT_READY";
@@ -15418,7 +15418,7 @@ int main (int argc, char **argv)
1541815418
case 'z': /* configure for Arcus zookeeper cluster */
1541915419
/* host_list in the form of
1542015420
-z 10.0.0.1:2181,10.0.0.2:2181,10.0.0.3:2181 */
15421-
arcus_zk_cfg = strdup(optarg);
15421+
arcus_zk_cfg = optarg;
1542215422
break;
1542315423
case 'o': /* Arcus Zookeeper session timeout */
1542415424
arcus_zk_to = atoi(optarg); // this value is in seconds
@@ -15913,7 +15913,6 @@ int main (int argc, char **argv)
1591315913
/* 7) destroy cluster config structure */
1591415914
if (arcus_zk_cfg) {
1591515915
arcus_zk_destroy();
15916-
free(arcus_zk_cfg);
1591715916
}
1591815917
#endif
1591915918

0 commit comments

Comments
 (0)