l...@gnu.org (Ludovic Courtès) writes:

> ni...@lysator.liu.se (Niels Möller) skribis:

>> Now, I think the problem is that the code reading from a gateway client
>> socket doesn't check if hard_limit > 0. Not entirely trivial to fix.
>> What needs to be done is to
>>
>> 1. Make gateway_commands.c:do_read_gateway check that flag,
>>
>>    if (self->connection->chain->hard_limit)
>>       ...
>>    In this case, return zero, but we also need to stop reading from the
>>    socket. Maybe one can have the caller, io.c:do_buffered_read, check if
>>    the return value is zero, and call lsh_oop_cancel_read_fd?
>>
>> 2. Somwhow use the wakeup mechanism (invoked from
>>    connection.c:do_connection_flow_controlled) to restart reading from
>>    the gateway socket.
>
> Any update on that?  :-)

Sorry, I doubt I'll be able to fix this problem any time soon.

I had another look now, and I think the code reading from the gateway
socket needs to be converted from using the io_buffered_read abstraction
to using the io_consuming_read. With io_buffered_read, the handler is
expected to either comsume all available data, or replace itself with a
new handler able to immediately process remaining data. This is used for
the main ssh connections, which starts with one or more text lines
before the first binary ssh packet, but it makes it hard to solve the
problem at hand.

While with io_consuming_read, the read callback io.c:do_consuming_read
will first do a READ_QUERY asking the handler how much data it wants.
This method could return 0, and then the select loop stops reading from
the socket. That should solve half of the problem (and the gateway code
doesn't need the handler-replacement thing).

Then the remaining problem is waking the gateway connections up. This
should be done via the connection->wakeup callback on the main ssh
connection. Which currently invokes channels.c:do_channels_wakeup. That
could almost be used as is, as long as each gateway client has at least
one channel open. But to really get it right, the main ssh connection
would need to have a list of all gateway sockets, and the wakeup
callback ought to call lsh_register_read_fd on each of those sockets.

(I'm not as fond of all of these objects and abstractions now as when I
wrote this code... The development version is organized a bit
differently).

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
_______________________________________________
lsh-bugs mailing list
lsh-bugs@lists.lysator.liu.se
http://lists.lysator.liu.se/mailman/listinfo/lsh-bugs

Reply via email to