www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: Using libSSH2 in fiber-based parallel system

Re: Using libSSH2 in fiber-based parallel system

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Tue, 14 Oct 2014 22:18:54 +0100

On 13 October 2014 11:55, Martin DraĆĄar <drasar_at_ics.muni.cz> wrote:
>
> I have a program that uses fibers as a mean for parallelism and would
> like to use libssh2 in it. However, some of these functions seem more
> apt for thread-based parallelism. I have in mind functions using e.g.
> the BLOCK_ADJUST macros.
>
> So I just want to ask you, if the following approach I want to use is
> the correct one. Instead of calling libssh2_session_handshake I have
> this cycle that is basically BLOCK_ADJUST sans keepalive:
>
> while (socket not read or written to)
> {
> session_startup(session, socket);
> yield(); // Pass execution to another fiber
> }
>
> I ask, because the session_startup function is not exported into public API.

Using libssh2 in non-blocking mode you bypass BLOCK_ADJUST altogether.
Maybe something like this?

int rc;
while((rc = libssh2_session_startup(session, socket)) != LIBSSH2_ERROR_EAGAIN)
{
    yield();
}

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 2014-10-14

the libssh2 team