Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B5C410B32 for ; Sun, 11 Jan 2015 18:01:10 +0000 (UTC) Received: (qmail 82199 invoked by uid 500); 11 Jan 2015 18:01:11 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 82161 invoked by uid 500); 11 Jan 2015 18:01:11 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 80962 invoked by uid 99); 11 Jan 2015 18:01:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2015 18:01:06 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of realrichardsharpe@gmail.com designates 209.85.192.174 as permitted sender) Received: from [209.85.192.174] (HELO mail-pd0-f174.google.com) (209.85.192.174) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2015 18:01:00 +0000 Received: by mail-pd0-f174.google.com with SMTP id fp1so26586162pdb.5 for ; Sun, 11 Jan 2015 10:00:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=d9Afo/3a4o4w71lEwtC+bOmu47pDINGSKA7B1xG++/M=; b=LTWNM4kTD7HplqfCClYcvLU27pHr/K8PSOED8vVDvyMS1wAXlwA7xl5IQI70YJA0LA hWp0d6z4/lasJaO8h2hxB9MkwgQotofNXloPJCYxY+GRYPHx6sQHKS7JQlbiCYjGfFck ud0dKba9jd+il556j/cdULa7k3OPrsM00HfBY8Zkfm8/iz9QIdBn4eBvpkKtg8OAsZGG c/xb16u6TR/hwX4/tKZ64cyFwhGIS5MF1kDvuHGC/UxCEVQBekR/JaRNYxYQ0RbjqR4m nBc8uf8W6jpVyS51rPYiLzvH1MvVKtkfxklLZuwEj3eUfEhbIfsd7QWELAuaM9UpN8wo yWng== MIME-Version: 1.0 X-Received: by 10.66.221.135 with SMTP id qe7mr38226009pac.26.1420999240517; Sun, 11 Jan 2015 10:00:40 -0800 (PST) Received: by 10.70.61.42 with HTTP; Sun, 11 Jan 2015 10:00:40 -0800 (PST) In-Reply-To: References: Date: Sun, 11 Jan 2015 10:00:40 -0800 Message-ID: Subject: Re: Help with what I am doing wrong with the C interface ... From: Richard Sharpe To: user@zookeeper.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Sun, Jan 11, 2015 at 9:59 AM, Richard Sharpe wrote: > Hi folks, > > I am not sure if this is the correct interface, however, I am trying > to develop a config backend for Samba that connects to Zookeeper. The > intent is that parts of Samba's smb.conf would be stored in zookeeper > to make life easier in clustered environments. > > I am constrained to use C both by the code I am working with and by > inclination. The examples in C are somewhat sparse. > > I am trying to use the sync interface at the moment and I get zero > children back when I call zoo_get_children, however, if I use cli_mt I > can see that there is one child node under /samba in zookeeper: > > [root@localhost zookeeper-3.4.6]# ./src/c/cli_mt localhost:2181 > Watcher SESSION_EVENT state =3D CONNECTED_STATE > Got a new session id: 0x14accb10de10004 > > ls / > time =3D 1 msec > /: rc =3D 0 > samba > zookeeper > time =3D 1 msec > ls /samba > time =3D 1 msec > /samba: rc =3D 0 > global > time =3D 1 msec > > I am pretty certain that I am asking for the children of /samba as my > logging code shows me that I am feeding that path to zoo_get_children > and when I had a bug that appended a trailing slash I got error -8 > back. > > Here are what I think are the relevant parts of the code I have at the mo= ment: > > ------- > static void zoo_watcher(zhandle_t *zzh, int type, int state, const char *= path, > void *context) > { > DEBUG(10, ("%s called\n",__func__)); > } > > ... > > zh =3D zookeeper_init(host_port, zoo_watcher, 30000, &myId, 0, 0)= ; > if (!zh) { > DEBUG(10, ("Problem with zookeeper_init: %s\n", > strerror(errno))); > } > > ... > > struct String_vector strings; > ... > > rc =3D zoo_get_children(zh, zookeeper_key, false, &strings); > -------------- > > There are hints in the test code for the C client interface that > perhaps I should be doing something real in the watcher function above > but I am not sure. > > Any hints would be appreciated. OK, it looks like the problem was my confusion between the single threaded library and the multi-threaded library. I was trying to use the _st library, but it seems I need more infrastructure for that. I wrote a small simple test program and after linking it with the _mt library things are working. --=20 Regards, Richard Sharpe (=E4=BD=95=E4=BB=A5=E8=A7=A3=E6=86=82=EF=BC=9F=E5=94=AF=E6=9C=89=E6=9D=9C= =E5=BA=B7=E3=80=82--=E6=9B=B9=E6=93=8D)