This is an automated email from the ASF dual-hosted git repository.
kezhuw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/master by this push:
new f6766eca9 ZOOKEEPER-4810: Fix buf data race at format_endpoint_info
f6766eca9 is described below
commit f6766eca95b318e6e675a97be029b2eb2397dd0d
Author: fanyang <[email protected]>
AuthorDate: Mon Jun 23 15:32:29 2025 +0800
ZOOKEEPER-4810: Fix buf data race at format_endpoint_info
ZOOKEEPER-4810: Fix buf data race at format_endpoint_info()
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.
Reviewers: kezhuw
Author: fanyang89
Closes #2140 from fanyang89/fix-c-client-format-endpoint-race
---
zookeeper-client/zookeeper-client-c/src/zookeeper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
index 701e3992b..c59da18a5 100644
--- a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
+++ b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
@@ -5121,11 +5121,11 @@ 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;
- char is_inet6 = 0; // poor man's boolean
+ char is_inet6 = 0; // poor man's boolean
#ifdef _WIN32
char * addrstring;
#endif