开发者

epoll re-registration: File exists

I've got this exception that happens on the server side (multi process server with fork()) when I try to reconnect a client straight after a disconnection. I'm using boost, but at now I don't understand the exactly instruction which throws the exception, because debug in multi-process is not simply for me.

However I suppose at this point:

io_service_.notify_fork(boost::asio::io_service::fork_child);

Any ideas?

Update

I'm using the 1.52 version of asio, so it supports the fork and the exception is in the child process. It happens at the third reconnection attempt, so if

  1. Connect the client
  2. Disconnect (forced by ctrl +c)
  3. Reconnect (all works)
  4. Disconnect
  5. Reconnect this client (or another client) throws the exception..

This is the code:

   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::f开发者_运维知识库ork_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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜