【发布时间】:2015-07-03 04:47:58
【问题描述】:
在我的代码中,我使用了 boost 库,并在 boost::thread: 中第一次运行时得到错误并发生:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'what():
pipe_select_interrupter: Too many open files.
我使用了ulimit,看到文件描述符是300000,我认为它不能被使用。
代码抛出错误:
CCohConnection *conn = new CCohConnection(this,CCohStack::GetIoService());
构造函数定义:
CCohConnection::CCohConnection(ICohClient *pClient,boost::asio::io_service &io_service):
m_pClient(pClient),m_oIoService(io_service),m_socket(io_service),m_resolver(io_service),m_timer(io_service)
{
printf("gouzao\n");
}
我的程序在这个构造函数中中断了,这里是ioservice的定义:
namespace coh{
class CCohStack
{
public:
static void Start();
static void Stop();
static boost::asio::io_service & GetIoService(){return sm_oIoService;}
private:
static boost::asio::io_service sm_oIoService;
static boost::asio::io_service::work *sm_oWork;
static boost::thread m_thread;
};
}
【问题讨论】:
-
我们需要更多代码 (SSCCE)。该代码没有显示资源的生命周期是如何实际管理的。