【发布时间】:2013-01-19 00:38:45
【问题描述】:
我有一个正在运行的pselect 正在等待 TCP 连接。 pselect 在它自己的线程中运行,因此我有一堆在运行。
我在那些pselect 上设置了超时,但是,当我运行sockstat 时,我似乎有一些永远不会关闭的连接。他们中的 99% 都这样做。当我关闭完全建立连接的客户端时,我会认为在超时时间之后,我将能够关闭这些套接字。我设置了断点来检查返回值是否为零,但它从未发生过。
这就是我所拥有的
if((ret == pselect(..., timeout, NULL) <0 ){
//check errors
} else if (ret == 0)
{
//close connection for timing out
//I never land here, even though I can close the client side (thus presumably closing the connection)
}
如果这是我的问题,我还能做些什么来调试?虽然我可以在 sockstat 中看到它们,但我很难准确判断哪些套接字 fd 处于打开状态。
【问题讨论】: