[英]ACE Reactor quits on interrupted system call
我有一個ACE反應器,它接受套接字連接並在這些連接上偵聽傳入的數據。 反應器在專用線程中運行。 這是線程的入口函數:
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;
}
偶爾, run_reactor_event_loop
以-1退出,並且errno
報告原因是“系統調用中斷”。 我該如何處理? 據我所知,我有兩個選擇:再次調用run_reactor_event_loop
或配置使用sigaction
和SA_RESTART
再次調用被中斷的調用。
run_reactor_event_loop
是否安全? SA_RESTART
有多安全? 例如,這是否意味着^ C不會停止我的應用程序? 檢查反應堆的構造方式。 ACE_Reactor :: open()cal,采用“重新啟動”參數(默認= false),該參數告訴它在中斷后自動重新啟動handle_events方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.