簡體   English   中英

ACE Reactor在中斷的系統調用中退出

[英]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或配置使用sigactionSA_RESTART再次調用被中斷的調用。

  1. 再次調用run_reactor_event_loop是否安全?
  2. ACE_Reactor :: restart方法有什么作用? 看起來應該重新啟動循環? 有幫助嗎?
  3. 開啟SA_RESTART有多安全? 例如,這是否意味着^ C不會停止我的應用程序?
  4. 還有其他方法可以處理這種情況嗎?

檢查反應堆的構造方式。 ACE_Reactor :: open()cal,采用“重新啟動”參數(默認= false),該參數告訴它在中斷后自動重新啟動handle_events方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM