connectionLost never reached after calling loseConnection: stuck in CLOSE_WAIT forever
|Reported by:||Stefano Debenedetti||Owned by:|
|Cc:||Stefano Debenedetti, jesstess||Branch:||
branch-diff, diff-cov, branch-cov, buildbot
A is a twisted.internet.tcp.Connection transport connecting a socket to a protocol. A has a producer C. A is a consumer of B. More than 64KB are written to A. At some point B gives up and tells A to stopProducing (loseConnection). A.loseConnection stops the reactor from reading OneA and starts it writing. A.doWrite happens:
- it finds the send buffer empty
- it finds a registered producer (C) and resumes it
C never produces any more bytes. After some time (reactor.callLater 0 is not enough), C unregisters itself from A. A takes note that it has no more producer, but does nothing about it. A's protocol's connectionLost is never called even if its peer shuts down the connection. A's socket is stuck in CLOSE_WAIT state forever with 1 byte in the Recv-Q and 0 bytes in Send-Q.
Exarkun said that the bug is likely that FileDescriptor.unregisterProducer doesn't do anything special when disconnecting=True.
Please see the attached file that demonstrates the problem.
Change History (29)
comment:7 Changed 6 years ago by
|Author:||jesstess → exarkun, jesstess|
|Branch:||branches/close_wait-forever-4719 → branches/close_wait-forever-4719-2|
comment:11 follow-up: 12 Changed 6 years ago by
|Author:||exarkun, jesstess → exarkun, demaledetti2|
|Owner:||changed from Glyph to Stefano Debenedetti|
comment:19 Changed 6 years ago by
|Owner:||Jean-Paul Calderone deleted|
|Priority:||normal → high|