Commit d285b5a5 authored by Philip Withnall's avatar Philip Withnall Committed by Olivier Crête
Browse files

agent: Always emit a readable callback when pseudo-TCP data arrives

Previously, the pseudo-TCP implementation’s readable() callback would
only be invoked when new data was received if it was enabled. The
callback is enabled by reading all data from the TCP input buffer until
EWOULDBLOCK is returned.

Reading all that data is not possible if the client buffer is of a
limited size, and can lead to livelocks if the client reads exactly the
number of bytes in the TCP input buffer (i.e. its buffer size matches
the TCP buffer fill level).

Instead, always invoke the readable() callback. This might be slightly
less performant, but the whole pseudo-TCP implementation is a shambles
anyway, and the callbacks need removing, so why not?
parent cf9d3f18
......@@ -1461,7 +1461,10 @@ process(PseudoTcpSocket *self, Segment *seg)
// If we have new data, notify the user
if (bNewData && priv->bReadEnable) {
priv->bReadEnable = FALSE;
/* priv->bReadEnable = FALSE; — removed so that we’re always notified of
* incoming pseudo-TCP data, rather than having to read the entire buffer
* on each readable() callback before the next callback is enabled.
* (When client-provided buffers are small, this is not possible.) */
if (priv->callbacks.PseudoTcpReadable)
priv->callbacks.PseudoTcpReadable(self, priv->callbacks.user_data);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment