<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><br><br><div>> Date: Wed, 4 Mar 2015 10:49:24 +0800<br>> From: namei.unix@gmail.com<br>> To: yuyanggg@gmail.com<br>> CC: sheepdog@lists.wpkg.org<br>> Subject: Re: [sheepdog] [PATCH] zookeeper: fix bug for default cluster id<br>> <br>> On Wed, Mar 04, 2015 at 10:45:55AM +0800, Yu Yang wrote:<br>> > From: Yu Yang <yuyang@cmss.chinamobile.com><br>> > <br>> > Signed-off-by: Yu Yang <yuyang@cmss.chinamobile.com><br>> > ---<br>> > sheep/cluster/zookeeper.c | 10 +++++++++-<br>> > 1 file changed, 9 insertions(+), 1 deletion(-)<br>> > <br>> > diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c<br>> > index 4f85043..929231b 100644<br>> > --- a/sheep/cluster/zookeeper.c<br>> > +++ b/sheep/cluster/zookeeper.c<br>> > @@ -1466,7 +1466,15 @@ static int zk_init(const char *option)<br>> > <br>> > sd_info("version %d.%d.%d, address %s, timeout %d", ZOO_MAJOR_VERSION,<br>> > ZOO_MINOR_VERSION, ZOO_PATCH_VERSION, hosts, zk_timeout);<br>> > - if (zk_connect(hosts, zk_watcher, zk_timeout) < 0)<br>> > + if (!strchr(hosts, '/')) {<br>> > + char *tmp = (char *)malloc((strlen(hosts) +<br>> > + strlen(DEFAULT_BASE) + 1)*sizeof(char));<br>> > + strncpy(tmp, hosts, strlen(hosts));<br>> > + strcat(tmp, DEFAULT_BASE);<br>> > + if (zk_connect(tmp, zk_watcher, zk_timeout) < 0)<br>> > + return -1;<br>> > + free(tmp);<br>> > + } else if (zk_connect(hosts, zk_watcher, zk_timeout) < 0)<br>> > return -1;<br>> > <br>> > timeo = zoo_recv_timeout(zhandle);<br>> > -- <br>> > 1.7.9.5<br>> > <br>> > -- <br>> > sheepdog mailing list<br>> > sheepdog@lists.wpkg.org<br>> > https://lists.wpkg.org/mailman/listinfo/sheepdog<br>> <br>> Pleaes describe what kind of problem this patch fixes in the commit log.<br>> <br>> Yuan<br>> -- <br>> sheepdog mailing list<br>> sheepdog@lists.wpkg.org<br>> https://lists.wpkg.org/mailman/listinfo/sheepdog<br><br>Should strncpy be replaced by pstrcpy?<br>I saw comments "<span class="c">NEVER use strncpy." </span> in util.c. <br><br>Roy<br></div> </div></body>
</html>