Re: ssh_threads_set_callbacks in multithreaded server
- Subject: Re: ssh_threads_set_callbacks in multithreaded server
- From: Aris Adamantiadis <aris@xxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 10 Jul 2015 09:32:50 +0200
- To: libssh@xxxxxxxxxx
Le 10/07/15 09:20, Andreas Schneider a écrit :
> On Thursday 09 July 2015 18:48:58 Игорь Коваленко wrote:
>> I try to create a multithreaded ssh server.
>> Main thread creates new session and accepts a connection. After acception
>> each session will be processed in separate thread.
>> while (1)
>> ssh_session session = ssh_new();
>> if (session == NULL)
>> fprintf(stderr, "Failed to allocate session\n");
>> /* Blocks until there is a new incoming connection. */
>> if (ssh_bind_accept(m_sshbind, session) != SSH_ERROR)
>> // start a new thread with session
>> // ...
>> In a session's thread new event is created and event loop is started.
>> Session is used only in its own thread (I hope so).
>> I'm using my own thread classes.
>> Do I need to call ssh_threads_set_callbacks with my own implementation of
>> callbacks? If so what should do thread_id function?
> All details are explained here ...
> * If pthreads is being used by your application (or your framework's backend),
> you must link with libssh_threads dynamic library and initialize threading
> with the ssh_threads_pthreads threading object.
> * If an other threading library is being used by your application, you must
> implement all the methods of the ssh_threads_callbacks_struct structure and
> initialize libssh with it.
Also libssh itself is threadsafe (even without the threading callbacks),
but it depends on libcrypto which is not. Symptoms vary from random
crashes during the initialization to insecure sharing of PRNG material.
Archive administrator: email@example.com