【问题标题】:ssh multithread server remains blocked in ssh_bind_acceptssh 多线程服务器在 ssh_bind_accept 中仍然被阻塞
【发布时间】:2013-10-30 20:51:20
【问题描述】:

我使用 libssh 5.5 实现了一个 SSH 服务器。 在端口 22 上运行一个连接到服务器的 ssh 客户端,一切正常。 当我尝试连接第二个客户端时出现问题(我使用 PUTTY ssh 终端作为客户端)。 ssh_bind_accept 中等待客户端连接的服务端线程没有激活,新打开的(第二个)终端明显‘死’了(第一个打开 终端工作正常)。

我想知道我是否缺少一些重要的设置。

这是我执行的调用:

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

基本上,我开发的服务器是基于这里的示例:How to use libssh as server?

必须支持多个客户端,我有一个监听器, 并且当创建连接时(从 ssh_bind_accept 返回),我创建一个新线程并在那里继续 ssh 连接。分叉后,我创建了新的绑定和会话,并让自己等待 ssh_bind 接受。 问题是打开第二个终端不会导致 ssh_bind_accept 返回。

【问题讨论】:

    标签: windows multithreading libssh


    【解决方案1】:

    在 fork 之后,您是否尝试在子进程中执行 ssh_bind_free(sshbind) ?在多个进程中同时拥有侦听器文件描述符可能会导致问题。

    阿里斯

    【讨论】:

    • 这不应该是一个评论吗?
    猜你喜欢
    • 2014-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-11
    • 1970-01-01
    • 2019-10-30
    • 1970-01-01
    • 2015-03-22
    相关资源
    最近更新 更多