You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Austin Shoemaker (JIRA)" <ji...@apache.org> on 2008/10/27 06:32:44 UTC

[jira] Created: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
--------------------------------------------------------------------------------------------------------

                 Key: ZOOKEEPER-208
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
             Project: Zookeeper
          Issue Type: Bug
          Components: c client
    Affects Versions: 3.0.0
         Environment: Linux
            Reporter: Austin Shoemaker
            Priority: Critical


The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads. Below is the original patch we made which fixes the problem.

The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

Patch for zookeeper-c-client-2.2.1/src/zookeeper.c (2008-06-09 on SF.net)

241c241
<     struct hostent *he;
---
> 	struct addrinfo hints, *res, *res0;
243,245d242
<     struct sockaddr_in *addr4;
<     struct sockaddr_in6 *addr6;
<     char **ptr;
247a245
> 	char *strtok_last;
263c261
<     host=strtok(hosts, ",");
---
>     host=strtok_r(hosts, ",", &strtok_last);
283,294c281,297
<         he = gethostbyname(host);
<         if (!he) {
<             LOG_ERROR(("could not resolve %s", host));
<             errno=EINVAL;
<             rc=ZBADARGUMENTS;
<             goto fail;
<         }
<
<         /* Setup the address array */
<         for(ptr = he->h_addr_list;*ptr != 0; ptr++) {
<             if (zh->addrs_count == alen) {
<                 void *tmpaddr;
---
> 		
> 		memset(&hints, 0, sizeof(hints));
> 		hints.ai_flags = AI_ADDRCONFIG;
> 		hints.ai_family = AF_UNSPEC;
> 		hints.ai_socktype = SOCK_STREAM;
> 		hints.ai_protocol = IPPROTO_TCP;
>
> 		if (getaddrinfo(host, port_spec, &hints, &res0) != 0) {
> 			LOG_ERROR(("getaddrinfo: %s\n", strerror(errno)));
> 			rc=ZSYSTEMERROR;
> 			goto fail;
> 		}
> 		
> 		for (res = res0; res; res = res->ai_next) {
> 			// Expand address list if needed
> 			if (zh->addrs_count == alen) {
> 				void *tmpaddr;
304,313c307,312
<             }
<             addr = &zh->addrs[zh->addrs_count];
<             addr4 = (struct sockaddr_in*)addr;
<             addr6 = (struct sockaddr_in6*)addr;
<             addr->sa_family = he->h_addrtype;
<             if (addr->sa_family == AF_INET) {
<                 addr4->sin_port = htons(port);
<                 memset(&addr4->sin_zero, 0, sizeof(addr4->sin_zero));
<                 memcpy(&addr4->sin_addr, *ptr, he->h_length);
<                 zh->addrs_count++;
---
> 			}
> 			
> 			// Copy addrinfo into address list
> 			addr = &zh->addrs[zh->addrs_count];
> 			switch (res->ai_family) {
> 			case AF_INET:
315,320c314
<             } else if (addr->sa_family == AF_INET6) {
<                 addr6->sin6_port = htons(port);
<                 addr6->sin6_scope_id = 0;
<                 addr6->sin6_flowinfo = 0;
<                 memcpy(&addr6->sin6_addr, *ptr, he->h_length);
<                 zh->addrs_count++;
---
> 			case AF_INET6:
322,327c316,328
<             } else {
<                 LOG_WARN(("skipping unknown address family %x for %s",
<                         addr->sa_family, zh->hostname));
<             }
<         }
<         host = strtok(0, ",");
---
> 				memcpy(addr, res->ai_addr, res->ai_addrlen);
> 				++zh->addrs_count;
> 				break;
> 			default:
> 				LOG_WARN(("skipping unknown address family %x for %s",
> 					res->ai_family, zh->hostname));
> 				break;
> 			}
> 		}
> 		
> 		freeaddrinfo(res0);
>
> 		host = strtok_r(0, ",", &strtok_last);
329a331
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Austin Shoemaker (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12648756#action_12648756 ] 

Austin Shoemaker commented on ZOOKEEPER-208:
--------------------------------------------

Chris, thanks for modifying my patch to comply with the project. I reattached it granting the license, let me know if I can help with anything else.

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-208:
-----------------------------------

    Fix Version/s: 3.1.0

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads. Below is the original patch we made which fixes the problem.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.
> Patch for zookeeper-c-client-2.2.1/src/zookeeper.c (2008-06-09 on SF.net)
> 241c241
> <     struct hostent *he;
> ---
> > 	struct addrinfo hints, *res, *res0;
> 243,245d242
> <     struct sockaddr_in *addr4;
> <     struct sockaddr_in6 *addr6;
> <     char **ptr;
> 247a245
> > 	char *strtok_last;
> 263c261
> <     host=strtok(hosts, ",");
> ---
> >     host=strtok_r(hosts, ",", &strtok_last);
> 283,294c281,297
> <         he = gethostbyname(host);
> <         if (!he) {
> <             LOG_ERROR(("could not resolve %s", host));
> <             errno=EINVAL;
> <             rc=ZBADARGUMENTS;
> <             goto fail;
> <         }
> <
> <         /* Setup the address array */
> <         for(ptr = he->h_addr_list;*ptr != 0; ptr++) {
> <             if (zh->addrs_count == alen) {
> <                 void *tmpaddr;
> ---
> > 		
> > 		memset(&hints, 0, sizeof(hints));
> > 		hints.ai_flags = AI_ADDRCONFIG;
> > 		hints.ai_family = AF_UNSPEC;
> > 		hints.ai_socktype = SOCK_STREAM;
> > 		hints.ai_protocol = IPPROTO_TCP;
> >
> > 		if (getaddrinfo(host, port_spec, &hints, &res0) != 0) {
> > 			LOG_ERROR(("getaddrinfo: %s\n", strerror(errno)));
> > 			rc=ZSYSTEMERROR;
> > 			goto fail;
> > 		}
> > 		
> > 		for (res = res0; res; res = res->ai_next) {
> > 			// Expand address list if needed
> > 			if (zh->addrs_count == alen) {
> > 				void *tmpaddr;
> 304,313c307,312
> <             }
> <             addr = &zh->addrs[zh->addrs_count];
> <             addr4 = (struct sockaddr_in*)addr;
> <             addr6 = (struct sockaddr_in6*)addr;
> <             addr->sa_family = he->h_addrtype;
> <             if (addr->sa_family == AF_INET) {
> <                 addr4->sin_port = htons(port);
> <                 memset(&addr4->sin_zero, 0, sizeof(addr4->sin_zero));
> <                 memcpy(&addr4->sin_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			}
> > 			
> > 			// Copy addrinfo into address list
> > 			addr = &zh->addrs[zh->addrs_count];
> > 			switch (res->ai_family) {
> > 			case AF_INET:
> 315,320c314
> <             } else if (addr->sa_family == AF_INET6) {
> <                 addr6->sin6_port = htons(port);
> <                 addr6->sin6_scope_id = 0;
> <                 addr6->sin6_flowinfo = 0;
> <                 memcpy(&addr6->sin6_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			case AF_INET6:
> 322,327c316,328
> <             } else {
> <                 LOG_WARN(("skipping unknown address family %x for %s",
> <                         addr->sa_family, zh->hostname));
> <             }
> <         }
> <         host = strtok(0, ",");
> ---
> > 				memcpy(addr, res->ai_addr, res->ai_addrlen);
> > 				++zh->addrs_count;
> > 				break;
> > 			default:
> > 				LOG_WARN(("skipping unknown address family %x for %s",
> > 					res->ai_family, zh->hostname));
> > 				break;
> > 			}
> > 		}
> > 		
> > 		freeaddrinfo(res0);
> >
> > 		host = strtok_r(0, ",", &strtok_last);
> 329a331
> >

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Reed updated ZOOKEEPER-208:
------------------------------------

    Status: Patch Available  (was: Open)

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.0.1, 3.1.0
>
>         Attachments: ZOOKEEPER-208.patch, zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt reassigned ZOOKEEPER-208:
--------------------------------------

    Assignee: Austin Shoemaker

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads. Below is the original patch we made which fixes the problem.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.
> Patch for zookeeper-c-client-2.2.1/src/zookeeper.c (2008-06-09 on SF.net)
> 241c241
> <     struct hostent *he;
> ---
> > 	struct addrinfo hints, *res, *res0;
> 243,245d242
> <     struct sockaddr_in *addr4;
> <     struct sockaddr_in6 *addr6;
> <     char **ptr;
> 247a245
> > 	char *strtok_last;
> 263c261
> <     host=strtok(hosts, ",");
> ---
> >     host=strtok_r(hosts, ",", &strtok_last);
> 283,294c281,297
> <         he = gethostbyname(host);
> <         if (!he) {
> <             LOG_ERROR(("could not resolve %s", host));
> <             errno=EINVAL;
> <             rc=ZBADARGUMENTS;
> <             goto fail;
> <         }
> <
> <         /* Setup the address array */
> <         for(ptr = he->h_addr_list;*ptr != 0; ptr++) {
> <             if (zh->addrs_count == alen) {
> <                 void *tmpaddr;
> ---
> > 		
> > 		memset(&hints, 0, sizeof(hints));
> > 		hints.ai_flags = AI_ADDRCONFIG;
> > 		hints.ai_family = AF_UNSPEC;
> > 		hints.ai_socktype = SOCK_STREAM;
> > 		hints.ai_protocol = IPPROTO_TCP;
> >
> > 		if (getaddrinfo(host, port_spec, &hints, &res0) != 0) {
> > 			LOG_ERROR(("getaddrinfo: %s\n", strerror(errno)));
> > 			rc=ZSYSTEMERROR;
> > 			goto fail;
> > 		}
> > 		
> > 		for (res = res0; res; res = res->ai_next) {
> > 			// Expand address list if needed
> > 			if (zh->addrs_count == alen) {
> > 				void *tmpaddr;
> 304,313c307,312
> <             }
> <             addr = &zh->addrs[zh->addrs_count];
> <             addr4 = (struct sockaddr_in*)addr;
> <             addr6 = (struct sockaddr_in6*)addr;
> <             addr->sa_family = he->h_addrtype;
> <             if (addr->sa_family == AF_INET) {
> <                 addr4->sin_port = htons(port);
> <                 memset(&addr4->sin_zero, 0, sizeof(addr4->sin_zero));
> <                 memcpy(&addr4->sin_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			}
> > 			
> > 			// Copy addrinfo into address list
> > 			addr = &zh->addrs[zh->addrs_count];
> > 			switch (res->ai_family) {
> > 			case AF_INET:
> 315,320c314
> <             } else if (addr->sa_family == AF_INET6) {
> <                 addr6->sin6_port = htons(port);
> <                 addr6->sin6_scope_id = 0;
> <                 addr6->sin6_flowinfo = 0;
> <                 memcpy(&addr6->sin6_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			case AF_INET6:
> 322,327c316,328
> <             } else {
> <                 LOG_WARN(("skipping unknown address family %x for %s",
> <                         addr->sa_family, zh->hostname));
> <             }
> <         }
> <         host = strtok(0, ",");
> ---
> > 				memcpy(addr, res->ai_addr, res->ai_addrlen);
> > 				++zh->addrs_count;
> > 				break;
> > 			default:
> > 				LOG_WARN(("skipping unknown address family %x for %s",
> > 					res->ai_family, zh->hostname));
> > 				break;
> > 			}
> > 		}
> > 		
> > 		freeaddrinfo(res0);
> >
> > 		host = strtok_r(0, ",", &strtok_last);
> 329a331
> >

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Reed updated ZOOKEEPER-208:
------------------------------------

    Fix Version/s: 3.0.1

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.0.1, 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12648750#action_12648750 ] 

Patrick Hunt commented on ZOOKEEPER-208:
----------------------------------------

Arg, jira won't allow me to wipe this.

I've also messaged the author directly through email. Let's see if that helps.


> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642868#action_12642868 ] 

Patrick Hunt commented on ZOOKEEPER-208:
----------------------------------------

Good find. We'd like to consider this patch for 3.1.0 but I'm afraid we need an explicit grand of license to ASF. See the "contributing your work" section of the HowToContribute ZooKeeper wiki page:
http://wiki.apache.org/hadoop/ZooKeeper/HowToContribute

Specifically you should "Attach" your patch file to this issue (see link on left hand side of this JIRA), specify the file and select the "grand license to asf ..." radio button. After attaching the file you can select the "submit patch" link (again, left hand side of this jira) to submit your patch for review by committers, if everything looks good we'll commit the change to svn. Thanks!

---------
Contributing your work

Finally, patches should be attached to an issue report in [WWW] Jira via the Attach File link on the issue's Jira. Please add a comment that asks for a code review following our code review checklist. Please note that the attachment should be granted license to ASF for inclusion in ASF works (as per the [WWW] Apache License ยง5). 
---------


> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads. Below is the original patch we made which fixes the problem.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.
> Patch for zookeeper-c-client-2.2.1/src/zookeeper.c (2008-06-09 on SF.net)
> 241c241
> <     struct hostent *he;
> ---
> > 	struct addrinfo hints, *res, *res0;
> 243,245d242
> <     struct sockaddr_in *addr4;
> <     struct sockaddr_in6 *addr6;
> <     char **ptr;
> 247a245
> > 	char *strtok_last;
> 263c261
> <     host=strtok(hosts, ",");
> ---
> >     host=strtok_r(hosts, ",", &strtok_last);
> 283,294c281,297
> <         he = gethostbyname(host);
> <         if (!he) {
> <             LOG_ERROR(("could not resolve %s", host));
> <             errno=EINVAL;
> <             rc=ZBADARGUMENTS;
> <             goto fail;
> <         }
> <
> <         /* Setup the address array */
> <         for(ptr = he->h_addr_list;*ptr != 0; ptr++) {
> <             if (zh->addrs_count == alen) {
> <                 void *tmpaddr;
> ---
> > 		
> > 		memset(&hints, 0, sizeof(hints));
> > 		hints.ai_flags = AI_ADDRCONFIG;
> > 		hints.ai_family = AF_UNSPEC;
> > 		hints.ai_socktype = SOCK_STREAM;
> > 		hints.ai_protocol = IPPROTO_TCP;
> >
> > 		if (getaddrinfo(host, port_spec, &hints, &res0) != 0) {
> > 			LOG_ERROR(("getaddrinfo: %s\n", strerror(errno)));
> > 			rc=ZSYSTEMERROR;
> > 			goto fail;
> > 		}
> > 		
> > 		for (res = res0; res; res = res->ai_next) {
> > 			// Expand address list if needed
> > 			if (zh->addrs_count == alen) {
> > 				void *tmpaddr;
> 304,313c307,312
> <             }
> <             addr = &zh->addrs[zh->addrs_count];
> <             addr4 = (struct sockaddr_in*)addr;
> <             addr6 = (struct sockaddr_in6*)addr;
> <             addr->sa_family = he->h_addrtype;
> <             if (addr->sa_family == AF_INET) {
> <                 addr4->sin_port = htons(port);
> <                 memset(&addr4->sin_zero, 0, sizeof(addr4->sin_zero));
> <                 memcpy(&addr4->sin_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			}
> > 			
> > 			// Copy addrinfo into address list
> > 			addr = &zh->addrs[zh->addrs_count];
> > 			switch (res->ai_family) {
> > 			case AF_INET:
> 315,320c314
> <             } else if (addr->sa_family == AF_INET6) {
> <                 addr6->sin6_port = htons(port);
> <                 addr6->sin6_scope_id = 0;
> <                 addr6->sin6_flowinfo = 0;
> <                 memcpy(&addr6->sin6_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			case AF_INET6:
> 322,327c316,328
> <             } else {
> <                 LOG_WARN(("skipping unknown address family %x for %s",
> <                         addr->sa_family, zh->hostname));
> <             }
> <         }
> <         host = strtok(0, ",");
> ---
> > 				memcpy(addr, res->ai_addr, res->ai_addrlen);
> > 				++zh->addrs_count;
> > 				break;
> > 			default:
> > 				LOG_WARN(("skipping unknown address family %x for %s",
> > 					res->ai_family, zh->hostname));
> > 				break;
> > 			}
> > 		}
> > 		
> > 		freeaddrinfo(res0);
> >
> > 		host = strtok_r(0, ",", &strtok_last);
> 329a331
> >

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Reed updated ZOOKEEPER-208:
------------------------------------

    Attachment: ZOOKEEPER-208.patch

Updated the tests to not look for usage of gethostbyname.

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.0.1, 3.1.0
>
>         Attachments: ZOOKEEPER-208.patch, zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-208:
-----------------------------------

    Comment: was deleted

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12649316#action_12649316 ] 

Hudson commented on ZOOKEEPER-208:
----------------------------------

Integrated in ZooKeeper-trunk #149 (See [http://hudson.zones.apache.org/hudson/job/ZooKeeper-trunk/149/])
    . Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active. (austin shoemaker, chris daroch and ben reed via mahadev)


> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.0.1, 3.1.0
>
>         Attachments: ZOOKEEPER-208.patch, zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Mahadev konar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mahadev konar updated ZOOKEEPER-208:
------------------------------------

    Resolution: Fixed
        Status: Resolved  (was: Patch Available)

committed ben's patch to revision 719063 in trunk 
and revision 719064 in 3.0 branch.

thanks ben, austin and chris.

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.0.1, 3.1.0
>
>         Attachments: ZOOKEEPER-208.patch, zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Reed updated ZOOKEEPER-208:
------------------------------------

    Hadoop Flags: [Reviewed]

+1 great work. We should include this in 3.0.1

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.0.1, 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-208:
-----------------------------------

    Status: Patch Available  (was: Open)

Great. Thanks much Austin!

I'm marking this as "patch submitted" on behalf of the author for consideration in 3.1.0.



> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-208:
-----------------------------------

    Description: 
The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.

The problem is resolved by using getaddrinfo and strtok_r in place of the older API.



  was:
The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads. Below is the original patch we made which fixes the problem.

The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

Patch for zookeeper-c-client-2.2.1/src/zookeeper.c (2008-06-09 on SF.net)

241c241
<     struct hostent *he;
---
> 	struct addrinfo hints, *res, *res0;
243,245d242
<     struct sockaddr_in *addr4;
<     struct sockaddr_in6 *addr6;
<     char **ptr;
247a245
> 	char *strtok_last;
263c261
<     host=strtok(hosts, ",");
---
>     host=strtok_r(hosts, ",", &strtok_last);
283,294c281,297
<         he = gethostbyname(host);
<         if (!he) {
<             LOG_ERROR(("could not resolve %s", host));
<             errno=EINVAL;
<             rc=ZBADARGUMENTS;
<             goto fail;
<         }
<
<         /* Setup the address array */
<         for(ptr = he->h_addr_list;*ptr != 0; ptr++) {
<             if (zh->addrs_count == alen) {
<                 void *tmpaddr;
---
> 		
> 		memset(&hints, 0, sizeof(hints));
> 		hints.ai_flags = AI_ADDRCONFIG;
> 		hints.ai_family = AF_UNSPEC;
> 		hints.ai_socktype = SOCK_STREAM;
> 		hints.ai_protocol = IPPROTO_TCP;
>
> 		if (getaddrinfo(host, port_spec, &hints, &res0) != 0) {
> 			LOG_ERROR(("getaddrinfo: %s\n", strerror(errno)));
> 			rc=ZSYSTEMERROR;
> 			goto fail;
> 		}
> 		
> 		for (res = res0; res; res = res->ai_next) {
> 			// Expand address list if needed
> 			if (zh->addrs_count == alen) {
> 				void *tmpaddr;
304,313c307,312
<             }
<             addr = &zh->addrs[zh->addrs_count];
<             addr4 = (struct sockaddr_in*)addr;
<             addr6 = (struct sockaddr_in6*)addr;
<             addr->sa_family = he->h_addrtype;
<             if (addr->sa_family == AF_INET) {
<                 addr4->sin_port = htons(port);
<                 memset(&addr4->sin_zero, 0, sizeof(addr4->sin_zero));
<                 memcpy(&addr4->sin_addr, *ptr, he->h_length);
<                 zh->addrs_count++;
---
> 			}
> 			
> 			// Copy addrinfo into address list
> 			addr = &zh->addrs[zh->addrs_count];
> 			switch (res->ai_family) {
> 			case AF_INET:
315,320c314
<             } else if (addr->sa_family == AF_INET6) {
<                 addr6->sin6_port = htons(port);
<                 addr6->sin6_scope_id = 0;
<                 addr6->sin6_flowinfo = 0;
<                 memcpy(&addr6->sin6_addr, *ptr, he->h_length);
<                 zh->addrs_count++;
---
> 			case AF_INET6:
322,327c316,328
<             } else {
<                 LOG_WARN(("skipping unknown address family %x for %s",
<                         addr->sa_family, zh->hostname));
<             }
<         }
<         host = strtok(0, ",");
---
> 				memcpy(addr, res->ai_addr, res->ai_addrlen);
> 				++zh->addrs_count;
> 				break;
> 			default:
> 				LOG_WARN(("skipping unknown address family %x for %s",
> 					res->ai_family, zh->hostname));
> 				break;
> 			}
> 		}
> 		
> 		freeaddrinfo(res0);
>
> 		host = strtok_r(0, ",", &strtok_last);
329a331
>



I've updated the summary now that the changes are attached. If the original author doesn't approve then perhaps we can get someone who's untainted to create a new patch.


> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12648757#action_12648757 ] 

phunt edited comment on ZOOKEEPER-208 at 11/18/08 1:18 PM:
------------------------------------------------------------------

Great. Thanks much Austin!

I'm marking this as "patch available" on behalf of the author for consideration in 3.1.0.



      was (Author: phunt):
    Great. Thanks much Austin!

I'm marking this as "patch submitted" on behalf of the author for consideration in 3.1.0.


  
> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-208:
-----------------------------------

    Status: Open  (was: Patch Available)

Cancelling the patch: the c unit tests are failing (ubuntu) with this patch applied:

Zookeeper_init::testAddressResolution : assertion
(more)

Also, I just realized - the configure.ac file should be updated for the new functions used (notice gethostbyname is there in .ac file, need to add strtok_r, getaddrinfo, etc... ).

Might also be a good idea to verify this build on window/linux/freebsd. It built fine on ubuntu.

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.0.1, 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Chris Darroch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Darroch updated ZOOKEEPER-208:
------------------------------------

    Attachment: zookeeper-strtok_getaddrinfo-trunk.patch

I've reformatted the original submitter's normal patch as a unified diff file to use against 3.0.0 and SVN trunk (at the moment).

I won't grant a license for it, though, since I didn't do the original work.

Hopefully this saves the submitter a little work.  If they can just sign off on this file, they shouldn't need to deal with any other details.

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads. Below is the original patch we made which fixes the problem.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.
> Patch for zookeeper-c-client-2.2.1/src/zookeeper.c (2008-06-09 on SF.net)
> 241c241
> <     struct hostent *he;
> ---
> > 	struct addrinfo hints, *res, *res0;
> 243,245d242
> <     struct sockaddr_in *addr4;
> <     struct sockaddr_in6 *addr6;
> <     char **ptr;
> 247a245
> > 	char *strtok_last;
> 263c261
> <     host=strtok(hosts, ",");
> ---
> >     host=strtok_r(hosts, ",", &strtok_last);
> 283,294c281,297
> <         he = gethostbyname(host);
> <         if (!he) {
> <             LOG_ERROR(("could not resolve %s", host));
> <             errno=EINVAL;
> <             rc=ZBADARGUMENTS;
> <             goto fail;
> <         }
> <
> <         /* Setup the address array */
> <         for(ptr = he->h_addr_list;*ptr != 0; ptr++) {
> <             if (zh->addrs_count == alen) {
> <                 void *tmpaddr;
> ---
> > 		
> > 		memset(&hints, 0, sizeof(hints));
> > 		hints.ai_flags = AI_ADDRCONFIG;
> > 		hints.ai_family = AF_UNSPEC;
> > 		hints.ai_socktype = SOCK_STREAM;
> > 		hints.ai_protocol = IPPROTO_TCP;
> >
> > 		if (getaddrinfo(host, port_spec, &hints, &res0) != 0) {
> > 			LOG_ERROR(("getaddrinfo: %s\n", strerror(errno)));
> > 			rc=ZSYSTEMERROR;
> > 			goto fail;
> > 		}
> > 		
> > 		for (res = res0; res; res = res->ai_next) {
> > 			// Expand address list if needed
> > 			if (zh->addrs_count == alen) {
> > 				void *tmpaddr;
> 304,313c307,312
> <             }
> <             addr = &zh->addrs[zh->addrs_count];
> <             addr4 = (struct sockaddr_in*)addr;
> <             addr6 = (struct sockaddr_in6*)addr;
> <             addr->sa_family = he->h_addrtype;
> <             if (addr->sa_family == AF_INET) {
> <                 addr4->sin_port = htons(port);
> <                 memset(&addr4->sin_zero, 0, sizeof(addr4->sin_zero));
> <                 memcpy(&addr4->sin_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			}
> > 			
> > 			// Copy addrinfo into address list
> > 			addr = &zh->addrs[zh->addrs_count];
> > 			switch (res->ai_family) {
> > 			case AF_INET:
> 315,320c314
> <             } else if (addr->sa_family == AF_INET6) {
> <                 addr6->sin6_port = htons(port);
> <                 addr6->sin6_scope_id = 0;
> <                 addr6->sin6_flowinfo = 0;
> <                 memcpy(&addr6->sin6_addr, *ptr, he->h_length);
> <                 zh->addrs_count++;
> ---
> > 			case AF_INET6:
> 322,327c316,328
> <             } else {
> <                 LOG_WARN(("skipping unknown address family %x for %s",
> <                         addr->sa_family, zh->hostname));
> <             }
> <         }
> <         host = strtok(0, ",");
> ---
> > 				memcpy(addr, res->ai_addr, res->ai_addrlen);
> > 				++zh->addrs_count;
> > 				break;
> > 			default:
> > 				LOG_WARN(("skipping unknown address family %x for %s",
> > 					res->ai_family, zh->hostname));
> > 				break;
> > 			}
> > 		}
> > 		
> > 		freeaddrinfo(res0);
> >
> > 		host = strtok_r(0, ",", &strtok_last);
> 329a331
> >

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-208) Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active

Posted by "Austin Shoemaker (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Austin Shoemaker updated ZOOKEEPER-208:
---------------------------------------

    Attachment: zookeeper-strtok_getaddrinfo-trunk.patch

Reattaching patch with license granted.

> Zookeeper C client uses API that are not thread safe, causing crashes when multiple instances are active
> --------------------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-208
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-208
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0
>         Environment: Linux
>            Reporter: Austin Shoemaker
>            Assignee: Austin Shoemaker
>            Priority: Critical
>             Fix For: 3.1.0
>
>         Attachments: zookeeper-strtok_getaddrinfo-trunk.patch, zookeeper-strtok_getaddrinfo-trunk.patch
>
>
> The Zookeeper C client library uses gethostbyname and strtok, both of which are not safe to use from multiple threads.
> The problem is resolved by using getaddrinfo and strtok_r in place of the older API.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.