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

Re: timeout in ssh_channel_accept


On Thursday, November 18, 2010 12:21:32 you wrote:
> Hello libssh developers,

Hi,

I'm back in action in mid December. I hope Aris has time to do the review.

	-- andreas

> I have found a code in channels.c, function
> 
> static ssh_channel ssh_channel_accept(ssh_session session, int channeltype,
>     int timeout_ms)
> 
> 
> 
> for (t = timeout_ms; t >= 0; t -= 50)
> {
> 
> ...................
> 
> #ifdef _WIN32
>       Sleep(50); /* 50ms */
> #else
>       nanosleep(&ts, NULL);
> #endif
> }
> 
> 
> 
> it make this function to sleep 50ms even if timeout_ms is 0.
> 
> f.e, I want to develop application which open reverse tunnel:
> 
> loop
> {
> 
>     ssh_channel newChan=channel_forward_accept(my_ssh_session,0);
>     if(newChan)
>     {
>          newSocket= connect to server
>     }
> 
>     ssh_select( ...... )
> }
> 
> In this case I calling function "channel_forward_accept" with timeout=0.
> I don't want this function to block execution of my thread. As result if
> I starting scp process over this tunnel, it is many times slower as scp
> over tunnel opened with "ssh -R". I attached a tiny patch, that make
> ssh_channel_accept not to wait 50 ms if timeout_ms is 0. Can you please
> accept it? With this patch my reverse tunnel created with libssh is as
> fast as tunnel created with "ssh -R".
> 
> regards,
> alex


References:
timeout in ssh_channel_acceptOleksandr Shneyder <oleksandr.shneyder@xxxxxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org