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

Re: Multithreading question


Hi Stefano,

you cannot use a single session in multiple threads concurrently. That
also applies to all channels created for that session. See here:
http://api.libssh.org/stable/libssh_tutor_threads.html

If you are talking about command execution via
ssh_channel_request_exec(), you will have to create a channel for each
command because the channel is closed when the command ends. Channel
reuse is not possible when running single commands. SFTP channels can be
reused.

Regards
Tilo Eckert

Am 30.03.2019 um 10:51 schrieb Stefano Mtangoo:
> Until now I have been using libssh on the main thread. But It is
> annoying as it will sometimes freeze the UI. Network woes sometimes
> makes UI freezing and that isn't nice. So I want to move all operations
> to another thread. But I have questions that I cannot find answers to:
> 1. If I store session in Main UI and pass it in every thread (sometimes
> mutiple threads will be running under same session) do I have to do
> locking or libssh provides one? The docs on MT seems to indicate that
> for dynamic linked DLL
> 
> 2. I plan to create new sftp object per thread with sftp_new(). What is
> the performance impact compared to psersisting it?
> 
> 3. I plan to create new channel for each command from same session when
> sending a command. How much is performance impacted compared to
> persisting a channel
> 
> I do simple command for file management via SFTP (CRUD) plus sending
> some commands to remote SSH server.
> 
> Thank you.
> 
> -- 
> for me to live is Christ to die is gain


Follow-Ups:
Re: Multithreading questionStefano Mtangoo <mwinjilisti@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org