Expired session id when reconnecting

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Expired session id when reconnecting

Austin Shoemaker
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

Reply | Threaded
Open this post in threaded view
|

Re: Expired session id when reconnecting

Patrick Hunt
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
>
>