You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Austin Shoemaker <au...@cooliris.com> on 2008/09/30 10:01:29 UTC

Expired session id when reconnecting

The documentation in zookeeper.h states:

  *   clientid the id of a previously established session that this
  *   client will be reconnecting to. Pass 0 if not reconnecting to a  
previous
  *   session. If the session timed out or the id is invalid, a new
  *   session will be automatically generated. Clients should check  
the actual
  *   session id by calling \ref zoo_client_id.

The implementation of zookeeper_init appears to enter  
EXPIRED_SESSION_STATE instead of automatically generating a new  
session id.

Would it be safe to remove this block in zookeeper.c check_events():

if (oldid != 0 && oldid != newid) {
     zh->state = EXPIRED_SESSION_STATE;
     errno = ESTALE;
     return handle_socket_error_msg(zh,__LINE__,ZSESSIONEXPIRED,
             "session %llx has expired.",oldid);
} else {

so that the new session continues to CONNECTED_STATE? It would be  
useful to receive a session expired notification without aborting the  
connection.

Thanks,

Austin


Re: Expired session id when reconnecting

Posted by Patrick Hunt <ph...@apache.org>.
There is a patch pending on this particular issue which I submitted last 
week.

https://issues.apache.org/jira/browse/ZOOKEEPER-17

I only changed the docs though, not the semantics of the method. Could 
you add your comments/suggestions there? Perhaps the patch should be 
changed, I'm not sure, I really just tried to make the comments reflect 
the current state of the api.

Patrick

Austin Shoemaker wrote:
> The documentation in zookeeper.h states:
> 
>  *   clientid the id of a previously established session that this
>  *   client will be reconnecting to. Pass 0 if not reconnecting to a 
> previous
>  *   session. If the session timed out or the id is invalid, a new
>  *   session will be automatically generated. Clients should check the 
> actual
>  *   session id by calling \ref zoo_client_id.
> 
> The implementation of zookeeper_init appears to enter 
> EXPIRED_SESSION_STATE instead of automatically generating a new session id.
> 
> Would it be safe to remove this block in zookeeper.c check_events():
> 
> if (oldid != 0 && oldid != newid) {
>     zh->state = EXPIRED_SESSION_STATE;
>     errno = ESTALE;
>     return handle_socket_error_msg(zh,__LINE__,ZSESSIONEXPIRED,
>             "session %llx has expired.",oldid);
> } else {
> 
> so that the new session continues to CONNECTED_STATE? It would be useful 
> to receive a session expired notification without aborting the connection.
> 
> Thanks,
> 
> Austin
> 
>