[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CHUNKSIZE in connector.c


Hi!

In the Multipass project [1], we use an ssh client implementation
similar to the ssh_client example where connectors are used.  We are
running into an issue where if a ssh_channel_request_exec() is called
via the client, that the client can "hang" if it is receiving large
amounts of data.

I narrowed this issue down to ssh_connector_fd_out_cb() and the
ssh_channel_read_nonblocking() call.  Whenever there is more data to be
read than CHUNKSIZE (which is 4096 bytes), then there is no way for the
code to go back and read more data on the particular event.  I found
that increasing CHUNKSIZE to 65536 bytes keeps the issue from
occurring.  This allows the buffer to be larger than the TCP max buffer
size and so all data in the packet will be accounted for.

I would like to propose increasing CHUNKSIZE to 65536, but I'm not sure
if there is some legacy reason why it's so small or if there is perhaps
a better way of handling more than 4096 bytes of data to be read on the
socket.  Also, increasing CHUNKSIZE should increase performance some
since everything can be read at once and not have to loop through to try
to see if more data is available.

Let me know what you think.

Thanks,
Chris Townsend

[1] https://github.com/CanonicalLtd/multipass


Follow-Ups:
Re: CHUNKSIZE in connector.cAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org