Skip to content

Commit

Permalink
ZOOKEEPER-4810: Fix buf data race at format_endpoint_info()
Browse files Browse the repository at this point in the history
format_endpoint_info() is widely called in the IO thread. And the
some ZOOAPIs will call this method too: zoo_cycle_next_server()
and zoo_get_current_server(). These APIs return the same static buffer
read/write by IO thread causes data race.
  • Loading branch information
fanyang89 committed Feb 20, 2024
1 parent 7074448 commit f938c5d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zookeeper-client/zookeeper-client-c/src/zookeeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -5111,7 +5111,7 @@ int zoo_add_auth(zhandle_t *zh,const char* scheme,const char* cert,

static const char* format_endpoint_info(const struct sockaddr_storage* ep)
{
static char buf[134] = { 0 };
static __thread char buf[134] = { 0 };
char addrstr[INET6_ADDRSTRLEN] = { 0 };
const char *fmtstring;
void *inaddr;
Expand Down

0 comments on commit f938c5d

Please sign in to comment.