Subject: data overload

data overload

From: Dave Hayden <>
Date: Wed, 27 Jun 2012 17:09:00 -0700

At the head of _libssh2_channel_read(), a while loop calls _libssh2_transport_read(), after this comment:

> Process all pending incoming packets in all states in order to "even out" the network readings. Tests prove that this way produces faster transfers.

That makes sense for file transfers where the server will wait for an acknowledgement, but in the case of a terminal session that's firehosing data at us faster than we can process, that winds up filling up all available memory--instead of just the network buffer. I changed that code to

        read_packet = _libssh2_list_first(&session->packets);

        while ( read_packet == NULL && rc > 0 )
                rc = _libssh2_transport_read(session);
                read_packet = _libssh2_list_first(&session->packets);

and it appears to fix this problem. Maybe there should be a channel or session setting, choosing between the two? Or a limit on the number of packets the session will buffer?


Received on 2012-06-28