need a way to prevent write from blocking

Bug #220680 reported by Christopher Armstrong
Affects Status Importance Assigned to Milestone

Bug Description

Right now the chat server example is trivial to DoS by writing a client that connects to the server but never reads, given that transport.write() blocks when the buffer is full.

Proposed solution: add an optional 'block=' argument to transport.write() which when False buffers data in Python instead of waiting for the kernel buffer to empty. Of course, this just chains the trivial attack from a blocking attack to a memory consumption attack. That means we'll need either a max size on the buffer or a timeout.

The default value of 'block=' is up for debate. Using native Twisted APIs, one could say that the "default" is to not "wait", since you have to go to extra effort to implement the producer API when you do want to wait. I'm tempted to use this to justify a default of False. AFAICT, it's only people who are writing "streaming" protocols, or protocols which send large amounts of data, which ever want to use block=True.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers