Skip to content

TCP Sockets not closed by TCPServer and StreamRequestHandler #50497

Closed

Description

@kristjanvalur
BPO 6248
Nosy @kristjanvalur
Superseder
  • bpo-6267: Cumulative patcc:h to http and xmlrpc
  • Files
  • socketserver.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2009-06-28.21:14:13.794>
    created_at = <Date 2009-06-09.16:55:37.459>
    labels = ['type-bug', 'library']
    title = 'TCP Sockets not closed by TCPServer and StreamRequestHandler'
    updated_at = <Date 2009-06-28.21:14:13.793>
    user = 'https://github.com/kristjanvalur'

    bugs.python.org fields:

    activity = <Date 2009-06-28.21:14:13.793>
    actor = 'kristjan.jonsson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-06-28.21:14:13.794>
    closer = 'kristjan.jonsson'
    components = ['Library (Lib)']
    creation = <Date 2009-06-09.16:55:37.459>
    creator = 'kristjan.jonsson'
    dependencies = []
    files = ['14245']
    hgrepos = []
    issue_num = 6248
    keywords = ['patch', 'needs review']
    message_count = 1.0
    messages = ['89152']
    nosy_count = 1.0
    nosy_names = ['kristjan.jonsson']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'closed'
    superseder = '6267'
    type = 'behavior'
    url = 'https://bugs.python.org/issue6248'
    versions = ['Python 2.7']

    Activity

    1. kristjanvalur commented on Jun 9, 2009

      kristjanvalurmannequin
      MannequinAuthor

      When an error occurs in a StreamRequestHandler, its wfile and rfile
      members are not closed. This causes the underlaying socket to stay
      alive and and it is therefore not closed, even when the SocketServer
      closes it in server.close_request(). This means that a client will not
      know that there is no one listening on the other end.

      This is due to incorrect error handling semantics in BaseRequestHandler.

      This patch fixes the error handling in BaseRequestHandler, ensuring that
      request.finish() is called when request.setup() has completed.

      I also add an explicit socket.shutdown() in TCPServer.close_request() to
      make sure that at least a half-close occurs even in the face of socket
      reference leaks.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Jun 9, 2009
    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions