You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Michael Xu <mx...@gmail.com> on 2010/09/17 18:10:06 UTC

c client "0" state?

Hi everyone

in the c client api:

Is it normal for zoo_state() to return zero (not one of the valid state
consts) when it is handling socket errors?


In the C Code, handle_error(), which handles socket errors,  sets the
zh->state to zero, 
==================
    if (!is_unrecoverable(zh))  
        zh->state = 0;
==================

If the handle is recoverable, why is the state set to zero, which is not
even a valid state const? 

Here's a use case where the state should be connecting, but instead is
zero:

1) c client connects to a zkserver
2) shutdown zkserver
3) zoo_state() returns zero on a valid zookeeper handle. 


We are using zoo_state() to get the state of the connection, and this is
a surprising returned value from this function.


Thanks,

michael


Re: c client "0" state?

Posted by Patrick Hunt <ph...@apache.org>.
Seems like a bug to me. Please enter a JIRA (if you haven't already).

Thanks,

Patrick

On Fri, Sep 17, 2010 at 9:10 AM, Michael Xu <mx...@gmail.com> wrote:

> Hi everyone
>
> in the c client api:
>
> Is it normal for zoo_state() to return zero (not one of the valid state
> consts) when it is handling socket errors?
>
>
> In the C Code, handle_error(), which handles socket errors,  sets the
> zh->state to zero,
> ==================
>    if (!is_unrecoverable(zh))
>        zh->state = 0;
> ==================
>
> If the handle is recoverable, why is the state set to zero, which is not
> even a valid state const?
>
> Here's a use case where the state should be connecting, but instead is
> zero:
>
> 1) c client connects to a zkserver
> 2) shutdown zkserver
> 3) zoo_state() returns zero on a valid zookeeper handle.
>
>
> We are using zoo_state() to get the state of the connection, and this is
> a surprising returned value from this function.
>
>
> Thanks,
>
> michael
>
>