FrancisHe created ZOOKEEPER-4538:
------------------------------------

             Summary: c client use a static global variable addr_rw_server to 
save a zhandle's member will cause problem if there are multiple zhandle 
connecting multiple ZooKeeper ensembles
                 Key: ZOOKEEPER-4538
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4538
             Project: ZooKeeper
          Issue Type: Bug
          Components: c client
            Reporter: FrancisHe


 

Since addr_rw_server is static global, if there are multiple zhandle 
corresponding to multiple ZooKeeper ensembles(e.g. a.zookeeper.com, 
b.zookeer.com), the global addr_rw_server may pointer to address of 
a.zookeer.com when we use zhandle of b.zookeeper.com:
{code:java}
static struct sockaddr_storage *addr_rw_server = 0;

// in ping_rw_server
addr_rw_server = rc ? &zh->addr_rw_server : 0; 

// in zookeeper_interest
if (addr_rw_server) {
    zh->addr_cur = *addr_rw_server;
    addr_rw_server = 0;
} else {
    // No need to delay -- grab the next server and attempt connection
    zoo_cycle_next_server(zh);
}{code}
 

 



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to