<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><br></div><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</div>
<div><br></div><div><br></div><div>pstrcpy is nice, </div><div>well, <span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">I also find strncpy is used in http.c & ops.c,</span></div><div><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">Maybe we need our own libs for basic utility instead of sys call, such as malloc/strcpy and so on?</span></div><div><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;"><br></span></div><div><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;"><br></span></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div><span style="font-family: 微软雅黑, Tahoma; font-size: 14px; line-height: normal;">Regards,</span></div><div><span style="font-family: 微软雅黑, Tahoma; font-size: 14px; line-height: normal;">Yang</span></div><div><span style="font-family: 微软雅黑, Tahoma; font-size: 14px; line-height: normal;"><br></span></div><div>yuyanggg@gmail.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div><br></div></blockquote>
</body></html>