[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ssh_threads_set_callbacks in multithreaded server
  [Thread Prev] | [Thread Next]
 
 
- Subject: Re: ssh_threads_set_callbacks in multithreaded server
- From: Игорь Коваленко <igor.a.kovalenko@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 10 Jul 2015 11:00:19 +0300
- To: libssh@xxxxxxxxxx
I don't understand what should do thread_id callback?
2015-07-10 10:32 GMT+03:00 Aris Adamantiadis <aris@xxxxxxxxxxxx>:
> Le 10/07/15 09:20, Andreas Schneider a écrit :
> > On Thursday 09 July 2015 18:48:58 Игорь Коваленко wrote:
> >> Hello!
> >>
> >> 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");
> >>                 continue;
> >>             }
> >>
> >>             /* 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 ...
> >
> > http://api.libssh.org/master/libssh_tutor_threads.html
> >
> > * 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.
>
>
| Re: ssh_threads_set_callbacks in multithreaded server | Andreas Schneider <asn@xxxxxxxxxxxxxx> | 
| ssh_threads_set_callbacks in multithreaded server | Игорь Коваленко <igor.a.kovalenko@xxxxxxxxx> | 
| Re: ssh_threads_set_callbacks in multithreaded server | Andreas Schneider <asn@xxxxxxxxxxxxxx> | 
| Re: ssh_threads_set_callbacks in multithreaded server | Aris Adamantiadis <aris@xxxxxxxxxxxx> | 

