[Twisted-Python] Reactor Spinning?
Moxie Marlinspike
moxie at thoughtcrime.org
Sun May 23 09:42:37 MDT 2010
Hey everyone, I've still been trying to track down this spin bug. What
I probably should have mentioned before is that these are SSL
connections. Looking through the 10.0 release code, I found the
_sendCloseAlert method in tcp.py: http://pastebin.com/gZKxHtN5
I feel like this is almost certainly the culprit. Most suspiciously,
there's an explicit empty write on pastebin-line 23:
os.write(self.socket.fileno(), '')
It looks to me like there's a code path where this write "succeeds," the
SSL socket reports that the connection is still not shut down, and then
the transport is resumed via startWriting and startReading. I assume
that this then repeats for as long as that socket is up.
This directly corresponds with the system calls I'm seeing (poll, empty
write, poll, empty write...)
I still don't have an entirely comprehensive grasp of whats' going on
here, but while these efforts to "cleanly" shut down the SSL connection
by exchanging alerts are heroic, I feel like it's much more common (and
probably good enough) to just send an alert and immediately close the
underlying socket.
- moxie
--
http://www.thoughtcrime.org
On 05/05/2010 01:01 PM, Itamar Turner-Trauring wrote:
>>
>> I've confirmed that when spinning the FD corresponds with a client
>> connection. What would you suggest logging that might provide some
>> insight?
>
> What is the transport's writeSomeData() method doing? Is it actually
> trying to write an empty string? Transition from/to writeable state may
> also be interesting, along with logging size of transport's buffer (so
> logging in stopWriting/startWriting).
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
More information about the Twisted-Python
mailing list