epoll重新注册:文件存在
当我尝试在断开连接后立即重新连接客户端时,在服务器端(带有fork()的多进程服务器)上发生了此异常。我正在使用boost,但是现在我不明白引发异常的确切指令,因为在多进程中调试对我而言并不简单。
但是我想在这一点上:
io_service_.notify_fork(boost::asio::io_service::fork_child);
有任何想法吗?
更新资料
我使用的是1.52版的asio,因此它支持fork,但子进程例外。它在第三次尝试重新连接时发生,所以如果
连接客户端
断开连接(由ctrl + c强制)
重新连接(所有作品)
断开
重新连接此客户端(或另一个客户端)将引发异常。
这是代码:
if (fork() == 0) //I\'m child process
{
io_service_.notify_fork(boost::asio::io_service::fork_prepare);
cout << \"I\'m child process and my PID is \" << getpid() << endl;
/*Notifies to the io_service_ the fork termination*/
try
{
io_service_.notify_fork(boost::asio::io_service::fork_child);
}
catch (boost::exception& e)
{ cout<<\"Exception in notify_fork child \"<< endl;
std::cerr << diagnostic_information(e) << std::endl;
}
/*Closes the listen socket which remains opened in the parent process to accept new connections*/
acceptor_.close();
}
else //I\'m the parent process
{
cout << \"I\'m the parent process and my PID is \" << getpid() << endl;
/*Notifies to the io_service_ the fork termination*/
try
{
io_service_.notify_fork(boost::asio::io_service::fork_parent);
}
catch (boost::exception& e)
{
cout<<\"Exception in notify_fork parent \"<< endl;
std::cerr << diagnostic_information(e) << std::endl;
}
socket_.close();
/*Listening to new connections*/
start_accept();
}
没有找到相关结果
已邀请:
0 个回复