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

Disable keepalives in server. #150

Merged
merged 5 commits into from
Aug 6, 2019
Merged

Disable keepalives in server. #150

merged 5 commits into from
Aug 6, 2019

Conversation

marcopeereboom
Copy link
Contributor

@marcopeereboom marcopeereboom commented Jul 25, 2019

Disable keep-alives and cull online connections on repeated client connections.

Fixes #149

The server doesn't always seem to detect when a client disappears off
the net. This diff adds a mechanism to knock current connections offline
if a duplicate ID comes in. This is annoying when the user may
accidentally have two zkclients open but it beats being locked out of
zkserver for hours at a time.
z.Dbg(idS, "handleSession forced offline: %v", rids)
z.Lock()
oldSc, ok := z.sessions[rids]
if ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can get rid of if else if you just do a if !ok instead.

@@ -659,8 +700,7 @@ func (z *ZKS) listen() error {
continue
}

conn.(*net.TCPConn).SetKeepAlive(true)
conn.(*net.TCPConn).SetKeepAlivePeriod(time.Second)
conn.(*net.TCPConn).SetKeepAlive(false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommend just removing altogether

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it being explicit and I don't know what the OS is doing underneath.

@marcopeereboom marcopeereboom merged commit e6ba61c into master Aug 6, 2019
@marcopeereboom marcopeereboom deleted the keepalive branch August 6, 2019 15:27
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

Successfully merging this pull request may close these issues.

[zkserver] Cull connections more aggressively
2 participants