Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZOOKEEPER-4810: Fix buf data race at format_endpoint_info() #2140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fanyang89
Copy link
Contributor

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.

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.
@fanyang89 fanyang89 force-pushed the fix-c-client-format-endpoint-race branch from f938c5d to 2357e16 Compare February 20, 2024 09:01
@@ -5111,11 +5111,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 };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a macro here to accommodate single thread version and different compilers ?

cc @ztzg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__thread will do nothing in st mode, generating the same asm as without it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants