The documentation states that if the client_id given to zookeeper_init is expired or invalid that a new session will be automatically generated, implying that it will proceed to the CONNECTED state.
In the implementation an expired or invalid client_id leads to the unrecoverable SESSION_EXPIRED_STATE, which requires closing and reopening a new connection with no client_id specified to continue.
Since the server has already assigned a replacement client_id it seems logical to follow the header documentation and proceed with the new value, which appears to be possible by removing the if-block that triggers the expired state in check_events (zookeeper.c).
If the client application needs to know if the session was replaced, it can simply compare the client_id it provided with the client_id upon entering CONNECTED_STATE.
What do you think?