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

Re: libssh thread support


Thanks for the response Aris. What do you think about the following 
attempt?

Since we cannot perform:

>> So, let C be a channel, you cannot do
>> thread 1:
>>  ssh_channel_read(C,...)
>> thread 2:
>>  ssh_channel_write(C, ...)

What if I do:

typedef struct channel_struct {
    ssh_channel read;
    ssh_channel write;
} channnels;
typedef channels* chan_t;

chan_t c;

thread 1:
    ssh_channel_read(c->read...);
thread 2:
    ssh_channel_write(c->write...);

When my client connects to the server I finish the key exchange, etc. and 
then request two channels to open -- one for reading and one for writing. 
I don't get any error message during the connection, and my reading and 
writing successfully start, but after about 30 packets worth of data 
everything stops (seems like a dead lock).  Is this still due to a lack of 
threading support with 0.4.9?  Will this method work when 0.5.0 is 
released?  Any estimate on when 0.5.0 will be released?

Ken





Aris Adamantiadis <aris@xxxxxxxxxxxx> 
04/18/2011 08:51 AM
Please respond to
libssh@xxxxxxxxxx


To
libssh@xxxxxxxxxx
cc

Subject
Re: libssh thread support






Hi Kenneth,

The version you have is the latest. 0.5 is not yet out. We made a lot of
internal modifications and wanted to be sure it was ok before releasing
it, hence the rc.

The treading support is very basic. The thing is that now libssh will
handle better the threading if you follow the rules in the documentation.
However your use case (writing in A, reading in B) is not yet doable. It
is possible to set up callbacks for the channel, as seen in callbacks.h
file.

Unfortunately we don't have any documentation or example for it yet.

Kr,

Aris

Le 15/04/11 23:06, Kenneth W Rohde a écrit :
> 
> Hello Everyone,
> 
> Just started using libssh and just subscribed to the listsrv.  This is a
> very relevant thread to me as I'm trying to write a client/server
> application with async communication.  I am coding both the client and
> server side using libssh.
> 
> I have a couple of questions:
> 
> 1. I think I'm using 0.5.0 (the tar file is named 0.4.91, but the SSH
> banner is 0.5.0).  Do I actually have the latest release of 0.5.0rc1?
> 2. I finally started using libssh after the 0.5.0 release due to the
> documentation claiming support for threads in 0.5.  If this is not
> allowed, what other options might I have for async?
> 
>> So, let C be a channel, you cannot do
>> thread 1:
>>  ssh_channel_read(C,...)
>> thread 2:
>>  ssh_channel_write(C, ...)
> 
> Is this limitation only when using 0.4?
> 
> Ken
> 
> 
> 
> 
> 
> *Andrew Tappert <andrew@xxxxxxxxxxxx>*
> 
> 04/14/2011 12:56 PM
> Please respond to
> libssh@xxxxxxxxxx
> 
> 
> 
> To
>                libssh@xxxxxxxxxx
> cc
>                Aris Adamantiadis <aris@xxxxxxxxxxxx>
> Subject
>                Re: libssh thread support
> 
> 
> 
> 
> 
> 
> 
> 
> 
> This leads me to think that threads aren't the right solution for me, so
> I explore other parts of your tutorial.  I see this:
> 
> "Warning: ssh_select() and ssh_channel_select() are not relevant
> anymore, since libssh is about to provide an easier system for
> asynchronous communications. This subsection should be removed then."
> 
> What is the easier system for asynchronous communications?  When will it
> be available?
> 
> Andrew
> 
> 
> On 04/14/2011 04:58 AM, Aris Adamantiadis wrote:
>> Hi,
>>
>> I see a typo in the tutorial. You should read "your *can't* use several
>> channels in a same session at the same time".
>> So, let C be a channel, you cannot do
>> thread 1:
>>  ssh_channel_read(C,...)
>> thread 2:
>>  ssh_channel_write(C, ...)
>>
>> You will have to use your own locking to avoid reads during your writes
>> and vice-versa.
>>
>> Kr,
>>
>> Aris
>>
>> Le 13/04/11 22:54, Andrew Tappert a écrit :
>>>
>>> I'm considering using libssh in an application I'm developing.  I 
would
>>> be using libssh to execute a program on the server, and my application
>>> would then speak an application-specific binary protocol with that
>>> program.  In this protocol, the requests and responses are 
asynchronous,
>>> so I would have a reader thread that reads "responses" from the ssh
>>> connection, while the main thread writes "requests" to it.  Is this
>>> possible with libssh?  Would I need locking so that a read and a write
>>> don't occur simultaneously?
>>>
>>> In the libssh tutorial, I see the following:
>>>
>>> "At all times, you may use different sessions inside threads, make
>>> parallel connections, read/write on different sessions and so on. You
>>> can use a single session in several channels at the same time. This 
will
>>> lead to internal state corruption. This limitation is being worked out
>>> and will maybe disappear later."
>>>
>>> Could you please clarify this statement?  I don't think it is clear 
what
>>> it is exactly that will lead to internal state corruption.
>>>
>>> Thanks,
>>> Andrew
> 
> 



References:
Re: libssh thread supportAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org