Subject: Re: Force deallocate all resources within session

Re: Force deallocate all resources within session

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Sat, 2 Mar 2013 16:57:48 +0000

On 22 February 2013 15:05, Anton Obukhov <anton_at_ubnt.com> wrote:
> Hi, I'm having the following scenario: I manage a bunch of remote devices,
> 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, session
> and resources, linked to the session.
>
> The problem is - if say the device went down, all the functions (including
> libssh2_session_free) return EAGAIN, and I seem to leak a lot of resources
> 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 & deallocate a
> 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 above.

Alex

-- 
Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-03-02