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

Optimize server connection close logic #1310

Merged
merged 3 commits into from Jun 5, 2022

Commits on Jun 4, 2022

  1. server.go Make code more clear

    Inline isHTTP11 var.
    Use direct Header.SetConnectionClose() and Header.ConnectionClose()
    stokito committed Jun 4, 2022
    Copy the full SHA
    4596f5a View commit details
    Browse the repository at this point in the history
  2. server.go Use direct SetConnectionClose()

    The SetCanonical(strConnection, strClose) call internally will anyway call SetConnectionClose().
    The "Connection: close" will be printed in the ResponseHeader.AppendBytes()
    stokito committed Jun 4, 2022
    Copy the full SHA
    b967294 View commit details
    Browse the repository at this point in the history
  3. server.go Simplify connectionClose evaluation

    The conn limit check merged into connectionClose evaluation.
    This improves performance for most cases:
    1. If the connectionClose already true then the conn limit check won't be performed.
    2. The SetConnectionClose() was duplicated
    3. First check conn limit and only then check for resp.connClose because most users don't close conns manually.
    4. We may optimize more: If the resp.connClose = true then SetConnectionClose() not needed but as mentioned above this is a rare case.
    stokito committed Jun 4, 2022
    Copy the full SHA
    3760b29 View commit details
    Browse the repository at this point in the history