>> Hi, I'm having the following scenario: I manage a bunch of remote
>> and some of them may sit on a bad connection. Whenever I detect that the
>> connection is unsatisfactory, I want to shutdown all the channels,
>> and resources, linked to the session.
>> The problem is - if say the device went down, all the functions
>> libssh2_session_free) return EAGAIN, and I seem to leak a lot of
>> if I keep it as is... So now all I do is I close the socket linked to the
>> session. What I'd like to do is to tell libssh to force close &
>> selected resource (channel, session, etc). Is there a way for it?
> You seem to be using the API in non-blocking mode but not using the
> functions in a non-blocking way.
> EAGAIN means that libssh2 hasn't finished executing the API call but
> is returning to let you know so that you can update you UI, or
> whatever, before *calling the same API again* with the same arguments.
> Keep calling this API until you get something other than EAGAIN. All
> libssh2 functions should be called this way in non-blocking mode.
> Alternatively, put libssh2 into blocking mode and forget all about the
Thanks for your suggestion Alex, but I'm using the non-blocking API exactly
as you advised: I call libssh2_session_free with the same paramerters
until either it returns something different than EAGAIN, or the timeout
happens. In my case, when the remote device goes down ungracefully, any
amount of seconds wait will result in timeout: I even tried 15 seconds. I
suppose resource destruction should be instant. It looks like libssh is
waiting for something inside there, whereas I want it to just free all
Received on 2013-03-03