Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection loss management #125

Open
GuillaumeDua opened this issue Oct 26, 2020 · 0 comments
Open

Connection loss management #125

GuillaumeDua opened this issue Oct 26, 2020 · 0 comments

Comments

@GuillaumeDua
Copy link

GuillaumeDua commented Oct 26, 2020

Idea :
zk::connection should provide a way to reconnect after a connection is loss,
as well as an atomic state

Considering the following example :

zk::connection con = zk::connection::connection("zk://addr:port/?opts");

// somewhere else ...

switch (con->state())
{  // handle some connection loss cases
   case zk::state::closed: [[fallthrough]];
   case zk::state::expired_session:
   {
	reset_connection(); // smthg like `con = zk::connection::connection("zk://addr:port/?opts");`
	break;
   }
   default:
	break;
}

In the sample above, the issue is the switch/case is error-prone, as erasing con content may result in invalid con->state() read in a concurrent context.
This force the user to create some blocking operation using memory barriers and perhaps condition_variales,
to ensure no wrong states are evaluated during connection reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant