Notify blocking problem of Ace_reactor

Source: Internet
Author: User

Today I heard a saying:

Ace_reactor notify may be blocked. Windwos and Linux are blocked by default when the message queue is full. Linux can be set to asynchronous, but when the Notify queue is full, the new signal will be lost, either asynchronously or blocked.

Signal Queue Length, Linux is the same as the number of file handles.

Today again Windwos test, when the signal is 1023 extra, the notify will block.

Linux under test ...

Windows test part of the code:

//T4l.cpp:Defines the entry point for the console application.//#include"stdafx.h"#include"ace/ace.h"#include"Ace/reactor.h"#include"ace/task_ex_t.h"#include"ace/sock_stream.h"#include"Ace/sock_acceptor.h"#include"ace/sock_connect.h"#include"Ace/sock_connector.h"#include"Ace/connector.h"#include"Ace/svc_handler.h"#include"Ace/os.h"#include"rapidjson/document.h"#include"Rapidjson/prettywriter.h"#include"Rapidjson/stringbuffer.h"classtestevent: PublicAce_task_ex<ace_mt_synch, testevent>{ Public:      Virtual intHandle_input (Ace_handle fd =ace_invalid_handle) {printf ("handle_input\n"); return 0; }            intPutq () {Ar_->notify ( This); return 0; }      Virtual intHandle_output (Ace_handle fd =ace_invalid_handle) {printf ("handle_output\n"); return 0; }      Virtual intHandle_exception (Ace_handle fd =ace_invalid_handle) {Size_++; printf ("handle_exception:%d\n", Size_); if(IS_SLEEP_) {Ace_os::sleep ( -); Is_sleep_=false; } ar_->remove_handler ( This, Ace_event_handler::except_mask); return 0; }  Virtual intHandle_timeout (ConstAce_time_value &Current_time,Const void*act =0) {Ace_time_value ATV (1,0);      Ace_os::sleep (ATV); //Ar_->remove_handler (this, ace_event_handler::except_mask);Ar_->cancel_timer ( This); printf ("handle_timeout\n"); return 0; }  Virtual intHandle_close (ace_handle handle, Ace_reactor_mask close_mask) {printf ("handle_close\n"); return 0; }  intOpen () {Size_=0; Is_sleep_=true; Ar_=ace_reactor::instance (); Ar_->register_handler ( This, Ace_event_handler::except_mask); Activate (THR_NEW_LWP| thr_joinable |thr_inherit_sched,1,0, ace_default_thread_priority); //ace_os::sleep (1);       for(intI=0; I <8900; i + +)      {          //ace_os::sleep (1);printf"opened:%d\n", i);      PUTQ (); } printf ("opened\n"); Ace_time_value ATV (1,0); Ace_reactor::instance ()->schedule_timer ( This, NULL, ATV, ATV); printf ("PUTQ Leave"); return 0; }  intSvc () {Ace_time_value TV= Ace_time_value (1,0); Ar_-owner (Ace_thread::self ()); //Ar_->run_reactor_event_loop ();         while(1)        {    //ace_reactor::instance ()->event_loop_done ();Ar_->handle_events (&TV); }    return 0; }Private: Ace_reactor*Ar_;    size_t Size_; BOOLIs_sleep_;};classServer: Publicace_event_handler{ Public:    intOpenConst Char*addr)        {ace_inet_addr ace_addr; if(-1= = Ace_addr.Set(Addr,strlen (addr))) {            returnAce_os::last_error (); }        intRET =Acceptor_.open (ACE_ADDR); Reactor_=NewAce_reactor;  This-reactor (REACTOR_);  This->reactor ()->register_handler ( This, Ace_event_handler::accept_mask); return 0; } Public:    inthandle_input (Ace_handle fd) {printf ("Connector (%d) comming\n", FD); } ace_handle Get_handle () {return  This-Acceptor_.get_handle (); }Private: Ace_sock_acceptor acceptor_; Ace_reactor*reactor_;};classConnectinst: PublicAce_svc_handler<ace_sock_stream,ace_mt_synch>{ Public: Connectinst (): Timeout_ ( +)    {    }    ~Connectinst () {}Private:    inttimeout_;};classclient{ Public:    intOpen () {reactor_=NewAce_reactor;        Connector_.open (REACTOR_); return 0; }    intConnectConst Char* Addr,intTime ) {Connectinst*Inst; intRET =connector_.connect (Inst, ace_inet_addr (ADDR)); }Private: Ace_connector<connectinst, ace_sock_connector>Connector_; Ace_reactor*reactor_;};intMainintargcChar*argv[]) {TestEvent* Te =Newtestevent (); Te-open (); Ace_reactor::instance ()-Run_reactor_event_loop (); Te-wait (); System ("Pause"); return 0;}

Notify blocking problem of Ace_reactor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.