Subject: Re: libssh2_channel_close/libssh2_channel_free hangs if you execute long-running command

Re: libssh2_channel_close/libssh2_channel_free hangs if you execute long-running command

From: Pavel Strashkin <pavel.strashkin_at_gmail.com>
Date: Fri, 14 Oct 2011 10:06:47 -0700

===SSH Connection Protocol===
   When either party wishes to terminate the channel, it sends
   SSH_MSG_CHANNEL_CLOSE. Upon receiving this message, a party MUST
   send back an SSH_MSG_CHANNEL_CLOSE unless it has already sent this
   message for the channel. The channel is considered closed for a
   party when it has both sent and received SSH_MSG_CHANNEL_CLOSE, and
   the party may then reuse the channel number. A party MAY send
   SSH_MSG_CHANNEL_CLOSE without having sent or received
   SSH_MSG_CHANNEL_EOF.
===SSH Connection Protocol===

The "terminate" word has the only meaning so i think it's a bug that
libssh2 waits for next channel data after user has called
libssh2_channel_close. The waiting period depends on how often the
program uses stdout/stderr.
If core developers agree with an issue i can spend my time for the
further investigation of such behavior and making the patch.

Implementation of signal's sending looks pretty easy. I can try to
make it too if nobody is working on it already.

2011/10/13 Henrik Nordström <henrik_at_henriknordstrom.net>:
> fre 2011-10-14 klockan 03:49 +0200 skrev Peter Stuge:
>> Pavel Strashkin wrote:
>> > Here we go. I read first block of data, then command "sleeps" for a
>> > [interval] seconds, i do libssh2_channel_close or
>> > libssh2_channel_free, and it hangs for [interval] seconds. I can't
>> > close channel or session graceful.
>>
>> Of course not, when the remote program still has the channel open?
>
> Can it after a CLOSE? (not EOF)
>
> Regards
> Henrik
>
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
>

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-10-14