|
- class ClientAcceptor : public ACE_Event_Handler
- {
- int open (const ACE_INET_Addr &listen_addr)
- {
- if (this->acceptor_.open (listen_addr, 1) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("acceptor.open")), -1);
- int ret = this->reactor ()->register_handler(this, ACE_Event_Handler::ACCEPT_MASK);
- return ret;
- }
- }
复制代码
就是这段代码(guide7.2节的Reactor例子的代码),程序在register_handler()这个调用这里阻塞了。
按照书上讲的,register_handler不是阻塞调用吧,怎么会阻塞的呢?
我用gdb输出了阻塞时的堆栈:
(gdb) bt
#0 0x40343332 in select () from /lib/libc.so.6
#1 0x4019fef8 in ?? () from /usr/lib/libACE.so.5.4.0
#2 0x00000000 in ?? ()
#3 0x00000007 in ?? ()
#4 0x400f8982 in ACE_Select_Reactor_T<ACE_Select_Reactor_Token_T<ACE_Token> >::wait_for_multiple_events (this=0x8056728,
dispatch_set=@0xbfffe390, max_wait_time=0xbfffe680) at OS_NS_sys_select.inl:31
#5 0x400f9fe4 in ACE_Select_Reactor_T<ACE_Select_Reactor_Token_T<ACE_Token> >::handle_events_i (this=0x8056728,
max_wait_time=0xbfffe680) at Select_Reactor_T.cpp:1455
#6 0x400f5c95 in ACE_Select_Reactor_T<ACE_Select_Reactor_Token_T<ACE_Token> >::handle_events (this=0x8056728,
max_wait_time=0xbfffe680) at Select_Reactor_T.cpp:1442
#7 0x400f5d43 in ACE_Select_Reactor_T<ACE_Select_Reactor_Token_T<ACE_Token> >::handle_events (this=0xfffffdfe,
max_wait_time=@0xbfffe680) at Select_Reactor_T.cpp:816
#8 0x400f5d63 in ACE_Select_Reactor_T<ACE_Select_Reactor_Token_T<ACE_Token> >::alertable_handle_events (this=0xfffffdfe,
max_wait_time=@0xbfffe680) at Select_Reactor_T.i:199
#9 0x4010490e in ACE_Reactor::alertable_handle_events (this=0x0, max_wait_time=@0xbfffe680) at Reactor.i:190
#10 0x0804b88f in ClientAcceptor::open ()
#11 0x0804b567 in main ()
根据堆栈的信息,好像是handle_register()里面居然调用了select(),然后程序就是阻塞在select()了,我就郁闷了,为什么handle_register()会调用select()?? 不是要到后面的loop里才会调用么select()么?
这到底是怎么回事? |
|