ACE Reactor quits on interrupted system call
I have an ACE reactor that accepts socket connections and listens for the incoming data on those connections. The reactor runs in a dedicated thread. This is the thread's entry function:
int TcpServer::svc()
{
LogDebug("The TCP server on %i is running", mLocalAddr.get_port_number());
// The current thread will own the reactor. By default, a reactor is owned by
// the creating thread. A reactor cannot run from not owning thread.
if (mReactor.owner(ACE_Thread::self()) != 0)
{
LogThrow("Could not change the owner of the reactor");
}
if (mReactor.run_reactor_event_loop() != 0)
{
LogWarning("Reactor loop has quit with an error.");
}
return 0;
}
Once in a while run_reactor_event_loop
exits with -1 and errno
reports that the reason is "interrupted system call". How can I handle the situation? From what I know I have two options: call run_reactor_event_loop
again or configure the interrupted call to be called again using sigaction
and SA_RESTART
.
- Is it safe to call
run_reactor_event_loop
again? - What does ACE_Reactor::restart method do? It looks like it is supposed to restart the loop? Will it 开发者_如何学Chelp?
- How safe it to turn on
SA_RESTART
? Does it mean, for example, that ^C won't stop my application? - Are there any other ways to handle the situation?
Check how Reactor is constructed. ACE_Reactor::open() cal, takes "restart" parameter (default = false) that tells it to restart handle_events method automatically after interruption.
精彩评论