ssh multithread server remains blocked in ssh_bind_accept

782 views Asked by At

I implemented an SSH server using libssh 5.5. Running a single ssh client connecting to the server on port 22, all works fine. The problem arises when I try to connect a second client (I use PUTTY ssh terminal as clients). The server thread waiting for a client connection in ssh_bind_accept is not activated, and the newly opened (second) terminal is obviously 'dead' (the first open terminal works correctly).

I wonder if there is something important to set that I'm missing.

Here are the calls i perform:

1. Create the session:

    sshbind = ssh_bind_new();
    session = ssh_new();

2. Call the listen:

    ssh_bind_listen(sshbind)

3. Call the accept:

     ssh_bind_accept( sshbind, session )

4. Open a putty terminal, which unlocks the *ssh_bind_accept* at step 3

5. Create a new thread and continue terminal dialogue in newly created thread

Basically, the server I developed is based on the sample here: How to use libssh as server?

Having to support multiple client terminals, I have a listener, and when a connection is created (return from ssh_bind_accept), I create a new thread and continue the ssh connection there. After forking, I create new bind and session, and put myself waiting in ssh_bind accept. The problem is that opening a second terminal, doesn't cause the ssh_bind_accept to return.

0

There are 0 answers