Opened 8 years ago

Last modified 8 years ago

#6751 defect reopened

— at twisted.web._newclient.Response leaves its transport in an unpredictable state depending on how large the response body isVersion 5

Reported by: Glyph Owned by:
Priority: high Milestone:
Component: web Keywords:
Cc: jknight Branch:

Description (last modified by Glyph)

If an HTTP response has a small response-body, and a Twisted application does not immediately call deliverBody when said response is received, Response can leave its transport paused.

When I say "immediately", I mean, synchronously within the response callback's invocation. If you call deliverBody at any point later, you go through the _deliverBody_DEFERRED_CLOSE callback which doesn't work.

Among other things, this means that when HTTP11ClientProtocol.quiescentCallback is invoked, the 'quiescent' connection might be reading (if it happened to go through _deliverBody_INITIAL) or it might be paused (if it happened to go through _deliverBody_DEFERRED_CLOSE).

This will lead to two negative effects:

  1. twisted.web.client.HTTPConnectionPool will end up adding paused connections to its persistent connection cache, and
  2. if something manages to be holding on to the transport, it'll silently hang around forever, leaking an FD; if nothing is holding on to it, it'll be GC'd, closing its socket (without calling connectionLost) some time later.

Change History (5)

comment:1 Changed 8 years ago by DefaultCC Plugin

Cc: jknight added

comment:2 Changed 8 years ago by Glyph

Description: modified (diff)

comment:3 Changed 8 years ago by Itamar Turner-Trauring

Resolution: duplicate
Status: newclosed

Duplicate of #6711 (but maybe you want to move the description over there, since it's better).

comment:4 Changed 8 years ago by Glyph

Resolution: duplicate
Status: closedreopened

Incorrect. This occurs even if you do call deliverBody.

comment:5 Changed 8 years ago by Glyph

Description: modified (diff)
Note: See TracTickets for help on using tickets.