From 0b69670efacfeede96629c55d26120e3deacfaa0 Mon Sep 17 00:00:00 2001 From: irfan Date: Mon, 29 Sep 1997 16:00:20 +0000 Subject: *** empty log message *** --- ace/Acceptor.cpp | 78 ++++++++++++++---- ace/Acceptor.h | 6 +- ace/LSOCK_Acceptor.cpp | 5 +- ace/LSOCK_Acceptor.h | 3 +- ace/Reactor.cpp | 15 ++-- ace/Reactor.h | 6 ++ ace/Reactor.i | 208 +++++++++++++++++++++++++----------------------- ace/SOCK_Acceptor.cpp | 30 ++++--- ace/SOCK_Acceptor.h | 6 +- ace/SPIPE_Acceptor.cpp | 5 +- ace/SPIPE_Acceptor.h | 3 +- ace/Service_Manager.cpp | 19 ++++- ace/Strategies_T.cpp | 32 ++++++-- ace/Strategies_T.h | 9 ++- ace/TLI_Acceptor.cpp | 3 + ace/TLI_Acceptor.h | 1 + ace/UPIPE_Acceptor.cpp | 5 +- ace/UPIPE_Acceptor.h | 3 +- 18 files changed, 287 insertions(+), 150 deletions(-) (limited to 'ace') diff --git a/ace/Acceptor.cpp b/ace/Acceptor.cpp index 03a1c376efc..a1562d30994 100644 --- a/ace/Acceptor.cpp +++ b/ace/Acceptor.cpp @@ -8,6 +8,7 @@ #include "ace/ACE.h" #include "ace/Acceptor.h" #include "ace/Handle_Set.h" +#include "ace/WFMO_Reactor.h" ACE_ALLOC_HOOK_DEFINE(ACE_Acceptor) @@ -221,7 +222,24 @@ ACE_Acceptor::accept_svc_handler (SVC_HANDLER *svc_handler) { ACE_TRACE ("ACE_Acceptor::accept_svc_handler"); - if (this->peer_acceptor_.accept (svc_handler->peer ()) == -1) + + int reset_new_handle = 0; +#if defined (ACE_WIN32) + // Try to find out if the implementation of the reactor that we are + // using is the WFMO_Reactor. If so we need to reset the event + // association for the newly created handle. This is because the + // newly created handle will inherit the properties of the listen + // handle, including its event associations. + if (dynamic_cast (this->reactor ()->implementation ())) + reset_new_handle = 1; +#endif /* ACE_WIN32 */ + + if (this->peer_acceptor_.accept (svc_handler->peer (), // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ) == -1) { // Close down handler to avoid memory leaks. svc_handler->close (0); @@ -250,19 +268,18 @@ ACE_Acceptor::activate_svc_handler if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0) { if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1) - return -1; + goto failure; } // Otherwise, make sure it's disabled by default. else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1) - return -1; - - if (svc_handler->open ((void *) this) == -1) - { - svc_handler->close (0); - return -1; - } - else + goto failure; + + if (svc_handler->open ((void *) this) != -1) return 0; + +failure: + svc_handler->close (0); + return -1; } // Template Method that makes a SVC_HANDLER (using the appropriate @@ -438,7 +455,7 @@ ACE_Strategy_Acceptor::open if (acc_s == 0) { - ACE_NEW_RETURN (acc_s, ACCEPT_STRATEGY, -1); + ACE_NEW_RETURN (acc_s, ACCEPT_STRATEGY (this->reactor ()), -1); this->delete_accept_strategy_ = 1; } this->accept_strategy_ = acc_s; @@ -831,15 +848,20 @@ ACE_Oneshot_Acceptor::shared_accept (SVC_HANDLER *svc_handler, ACE_PEER_ACCEPTOR_ADDR *remote_addr, ACE_Time_Value *timeout, - int restart) + int restart, + int reset_new_handle) { ACE_TRACE ("ACE_Oneshot_Acceptor::shared_accept"); if (svc_handler == 0) return -1; // Accept connection into the Svc_Handler. - else if (this->peer_acceptor_.accept (svc_handler->peer (), remote_addr, - timeout, restart) == -1) + else if (this->peer_acceptor_.accept (svc_handler->peer (), // stream + remote_addr, // remote address + timeout, // timeout + restart, // restart + reset_new_handle // reset new handle + ) == -1) { // Check whether we just timed out or whether we failed... if (!(errno == EWOULDBLOCK || errno == ETIMEDOUT)) @@ -864,7 +886,8 @@ ACE_Oneshot_Acceptor::accept (SVC_HANDLER *svc_handler, ACE_PEER_ACCEPTOR_ADDR *remote_addr, const ACE_Synch_Options &synch_options, - int restart) + int restart, + int reset_new_handle) { ACE_TRACE ("ACE_Oneshot_Acceptor::accept"); // Note that if timeout == ACE_Time_Value (x, y) where (x > 0 || y > @@ -882,7 +905,12 @@ ACE_Oneshot_Acceptor::accept else timeout = (ACE_Time_Value *) synch_options.time_value (); - if (this->shared_accept (svc_handler, remote_addr, timeout, restart) == -1) + if (this->shared_accept (svc_handler, // stream + remote_addr, // remote address + timeout, // timeout + restart, // restart + reset_new_handle // reset new handler + ) == -1) { if (use_reactor && errno == EWOULDBLOCK) // We couldn't accept right away, so let's wait in the ACE_Reactor. @@ -904,7 +932,23 @@ ACE_Oneshot_Acceptor::handle_input (ACE_HANDLE // Cancel any timer that might be pending. this->cancel (); - if (this->shared_accept (this->svc_handler_, 0, 0, this->restart_) == -1) + int reset_new_handle = 0; +#if defined (ACE_WIN32) + // Try to find out if the implementation of the reactor that we are + // using is the WFMO_Reactor. If so we need to reset the event + // association for the newly created handle. This is because the + // newly created handle will inherit the properties of the listen + // handle, including its event associations. + if (dynamic_cast (this->reactor ()->implementation ())) + reset_new_handle = 1; +#endif /* ACE_WIN32 */ + + if (this->shared_accept (this->svc_handler_, // stream + 0, // remote address + 0, // timeout + this->restart_, // restart + reset_new_handle // reset new handle + ) == -1) result = -1; if (this->reactor () && this->reactor ()->remove_handler (this, ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL) == -1) diff --git a/ace/Acceptor.h b/ace/Acceptor.h index f25a7727c1e..6c62f1c1a24 100644 --- a/ace/Acceptor.h +++ b/ace/Acceptor.h @@ -371,7 +371,8 @@ public: virtual int accept (SVC_HANDLER * = 0, ACE_PEER_ACCEPTOR_ADDR *remote_addr = 0, const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, - int restart = 1); + int restart = 1, + int reset_new_handle = 0); // Create a SVC_HANDLER, accept the connection into the SVC_HANDLER, // and activate the SVC_HANDLER. @@ -405,7 +406,8 @@ protected: int shared_accept (SVC_HANDLER *svc_handler, ACE_PEER_ACCEPTOR_ADDR *remote_addr, ACE_Time_Value *timeout, - int restart); + int restart, + int reset_new_handle); // Factors out the code shared between the and // methods. diff --git a/ace/LSOCK_Acceptor.cpp b/ace/LSOCK_Acceptor.cpp index e3adf489576..7a0f9d5883a 100644 --- a/ace/LSOCK_Acceptor.cpp +++ b/ace/LSOCK_Acceptor.cpp @@ -72,11 +72,12 @@ int ACE_LSOCK_Acceptor::accept (ACE_LSOCK_Stream &new_local_ipc_sap, ACE_Addr *remote_addr, ACE_Time_Value *timeout, - int restart) const + int restart, + int reset_new_handle) const { ACE_TRACE ("ACE_LSOCK_Acceptor::accept"); ACE_HANDLE new_handle = - ACE_SOCK_Acceptor::shared_accept (remote_addr, timeout, restart); + ACE_SOCK_Acceptor::shared_accept (remote_addr, timeout, restart, reset_new_handle); new_local_ipc_sap.set_handle (new_handle); return new_handle == ACE_INVALID_HANDLE ? -1 : 0; } diff --git a/ace/LSOCK_Acceptor.h b/ace/LSOCK_Acceptor.h index 2c262e2b66a..e576b6b9a49 100644 --- a/ace/LSOCK_Acceptor.h +++ b/ace/LSOCK_Acceptor.h @@ -51,7 +51,8 @@ public: int accept (ACE_LSOCK_Stream &new_ipc_sap, ACE_Addr * = 0, ACE_Time_Value *timeout = 0, - int restart = 1) const; + int restart = 1, + int reset_new_handle = 0) const; // Accept a new data transfer connection. int remove (void); diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index e5c53b43142..b6b9dea50fb 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -16,17 +16,20 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Reactor) -ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *implementation) - : implementation_ (implementation), +ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *impl) + : implementation_ (0), delete_implementation_ (0) { - if (this->implementation_ == 0) + this->implementation (impl); + + if (this->implementation () == 0) { #if defined (ACE_WIN32) && !defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) - ACE_NEW (this->implementation_, ACE_WFMO_Reactor); + ACE_NEW (impl, ACE_WFMO_Reactor); #else /* ACE_WIN32 && !ACE_USE_SELECT_REACTOR_AS_REACTOR */ - ACE_NEW (this->implementation_, ACE_Select_Reactor); + ACE_NEW (impl, ACE_Select_Reactor); #endif /* ACE_WIN32 && !ACE_USE_SELECT_REACTOR_AS_REACTOR */ + this->implementation (impl); this->delete_implementation_ = 1; } } @@ -34,7 +37,7 @@ ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *implementation) ACE_Reactor::~ACE_Reactor (void) { if (this->delete_implementation_) - delete this->implementation_; + delete this->implementation (); } // Process-wide ACE_Reactor. diff --git a/ace/Reactor.h b/ace/Reactor.h index 926140586a5..b3da1fc9b64 100644 --- a/ace/Reactor.h +++ b/ace/Reactor.h @@ -399,11 +399,17 @@ public: int ops); // GET/SET/ADD/CLR the ready "bit" bound with the and . + virtual ACE_Reactor_Impl *implementation (void); + // Get the implementation class + ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. protected: + virtual void implementation (ACE_Reactor_Impl *implementation); + // Set the implementation class + ACE_Reactor_Impl *implementation_; // Delegation/implementation class that all methods will be // forwarded to diff --git a/ace/Reactor.i b/ace/Reactor.i index 8312bb52d54..18d4620b6fe 100644 --- a/ace/Reactor.i +++ b/ace/Reactor.i @@ -10,40 +10,40 @@ ACE_Reactor::open (size_t size, ACE_Sig_Handler *signal_handler, ACE_Timer_Queue *timer_queue) { - return this->implementation_->open (size, - restart, - signal_handler, - timer_queue); + return this->implementation ()->open (size, + restart, + signal_handler, + timer_queue); } ACE_INLINE int ACE_Reactor::close (void) { - return this->implementation_->close (); + return this->implementation ()->close (); } ACE_INLINE int ACE_Reactor::handle_events (ACE_Time_Value *max_wait_time) { - return this->implementation_->handle_events (max_wait_time); + return this->implementation ()->handle_events (max_wait_time); } ACE_INLINE int ACE_Reactor::alertable_handle_events (ACE_Time_Value *max_wait_time) { - return this->implementation_->alertable_handle_events (max_wait_time); + return this->implementation ()->alertable_handle_events (max_wait_time); } ACE_INLINE int ACE_Reactor::handle_events (ACE_Time_Value &max_wait_time) { - return this->implementation_->handle_events (max_wait_time); + return this->implementation ()->handle_events (max_wait_time); } ACE_INLINE int ACE_Reactor::alertable_handle_events (ACE_Time_Value &max_wait_time) { - return this->implementation_->alertable_handle_events (max_wait_time); + return this->implementation ()->alertable_handle_events (max_wait_time); } @@ -51,8 +51,8 @@ ACE_INLINE int ACE_Reactor::register_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) { - int result = this->implementation_->register_handler (event_handler, - mask); + int result = this->implementation ()->register_handler (event_handler, + mask); if (result != -1) // Assign *this* to the . event_handler->reactor (this); @@ -65,9 +65,9 @@ ACE_Reactor::register_handler (ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) { - int result = this->implementation_->register_handler (io_handle, - event_handler, - mask); + int result = this->implementation ()->register_handler (io_handle, + event_handler, + mask); if (result != -1) // Assign *this* to the . event_handler->reactor (this); @@ -81,8 +81,8 @@ ACE_INLINE int ACE_Reactor::register_handler (ACE_Event_Handler *event_handler, ACE_HANDLE event_handle) { - int result = this->implementation_->register_handler (event_handler, - event_handle); + int result = this->implementation ()->register_handler (event_handler, + event_handle); if (result != -1) // Assign *this* to the . event_handler->reactor (this); @@ -98,10 +98,10 @@ ACE_Reactor::register_handler (ACE_HANDLE event_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) { - int result = this->implementation_->register_handler (event_handle, - io_handle, - event_handler, - mask); + int result = this->implementation ()->register_handler (event_handle, + io_handle, + event_handler, + mask); if (result != -1) // Assign *this* to the . event_handler->reactor (this); @@ -114,9 +114,9 @@ ACE_Reactor::register_handler (const ACE_Handle_Set &handles, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) { - int result = this->implementation_->register_handler (handles, - event_handler, - mask); + int result = this->implementation ()->register_handler (handles, + event_handler, + mask); if (result != -1) // Assign *this* to the . event_handler->reactor (this); @@ -131,11 +131,11 @@ ACE_Reactor::register_handler (int signum, ACE_Event_Handler **old_sh, ACE_Sig_Action *old_disp) { - return this->implementation_->register_handler (signum, - new_sh, - new_disp, - old_sh, - old_disp); + return this->implementation ()->register_handler (signum, + new_sh, + new_disp, + old_sh, + old_disp); } ACE_INLINE int @@ -143,33 +143,33 @@ ACE_Reactor::register_handler (const ACE_Sig_Set &sigset, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp) { - return this->implementation_->register_handler (sigset, - new_sh, - new_disp); + return this->implementation ()->register_handler (sigset, + new_sh, + new_disp); } ACE_INLINE int ACE_Reactor::remove_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask) { - return this->implementation_->remove_handler (event_handler, - mask); + return this->implementation ()->remove_handler (event_handler, + mask); } ACE_INLINE int ACE_Reactor::remove_handler (ACE_HANDLE handle, ACE_Reactor_Mask mask) { - return this->implementation_->remove_handler (handle, - mask); + return this->implementation ()->remove_handler (handle, + mask); } ACE_INLINE int ACE_Reactor::remove_handler (const ACE_Handle_Set &handle_set, ACE_Reactor_Mask mask) { - return this->implementation_->remove_handler (handle_set, - mask); + return this->implementation ()->remove_handler (handle_set, + mask); } ACE_INLINE int @@ -178,65 +178,65 @@ ACE_Reactor::remove_handler (int signum, ACE_Sig_Action *old_disp, int sigkey) { - return this->implementation_->remove_handler (signum, - new_disp, - old_disp, - sigkey); + return this->implementation ()->remove_handler (signum, + new_disp, + old_disp, + sigkey); } ACE_INLINE int ACE_Reactor::remove_handler (const ACE_Sig_Set &sigset) { - return this->implementation_->remove_handler (sigset); + return this->implementation ()->remove_handler (sigset); } ACE_INLINE int ACE_Reactor::suspend_handler (ACE_Event_Handler *event_handler) { - return this->implementation_->suspend_handler (event_handler); + return this->implementation ()->suspend_handler (event_handler); } ACE_INLINE int ACE_Reactor::suspend_handler (ACE_HANDLE handle) { - return this->implementation_->suspend_handler (handle); + return this->implementation ()->suspend_handler (handle); } ACE_INLINE int ACE_Reactor::suspend_handler (const ACE_Handle_Set &handles) { - return this->implementation_->suspend_handler (handles); + return this->implementation ()->suspend_handler (handles); } ACE_INLINE int ACE_Reactor::suspend_handlers (void) { - return this->implementation_->suspend_handlers (); + return this->implementation ()->suspend_handlers (); } ACE_INLINE int ACE_Reactor::resume_handler (ACE_Event_Handler *event_handler) { - return this->implementation_->resume_handler (event_handler); + return this->implementation ()->resume_handler (event_handler); } ACE_INLINE int ACE_Reactor::resume_handler (ACE_HANDLE handle) { - return this->implementation_->resume_handler (handle); + return this->implementation ()->resume_handler (handle); } ACE_INLINE int ACE_Reactor::resume_handler (const ACE_Handle_Set &handles) { - return this->implementation_->resume_handler (handles); + return this->implementation ()->resume_handler (handles); } ACE_INLINE int ACE_Reactor::resume_handlers (void) { - return this->implementation_->resume_handlers (); + return this->implementation ()->resume_handlers (); } @@ -246,18 +246,18 @@ ACE_Reactor::schedule_timer (ACE_Event_Handler *event_handler, const ACE_Time_Value &delta, const ACE_Time_Value &interval) { - return this->implementation_->schedule_timer (event_handler, - arg, - delta, - interval); + return this->implementation ()->schedule_timer (event_handler, + arg, + delta, + interval); } ACE_INLINE int ACE_Reactor::cancel_timer (ACE_Event_Handler *event_handler, int dont_call_handle_close) { - return this->implementation_->cancel_timer (event_handler, - dont_call_handle_close); + return this->implementation ()->cancel_timer (event_handler, + dont_call_handle_close); } ACE_INLINE int @@ -265,9 +265,9 @@ ACE_Reactor::cancel_timer (long timer_id, const void **arg, int dont_call_handle_close) { - return this->implementation_->cancel_timer (timer_id, - arg, - dont_call_handle_close); + return this->implementation ()->cancel_timer (timer_id, + arg, + dont_call_handle_close); } @@ -275,32 +275,32 @@ ACE_INLINE int ACE_Reactor::schedule_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_added) { - return this->implementation_->schedule_wakeup (event_handler, - masks_to_be_added); + return this->implementation ()->schedule_wakeup (event_handler, + masks_to_be_added); } ACE_INLINE int ACE_Reactor::schedule_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_added) { - return this->implementation_->schedule_wakeup (handle, - masks_to_be_added); + return this->implementation ()->schedule_wakeup (handle, + masks_to_be_added); } ACE_INLINE int ACE_Reactor::cancel_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_cleared) { - return this->implementation_->cancel_wakeup (event_handler, - masks_to_be_cleared); + return this->implementation ()->cancel_wakeup (event_handler, + masks_to_be_cleared); } ACE_INLINE int ACE_Reactor::cancel_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_cleared) { - return this->implementation_->cancel_wakeup (handle, - masks_to_be_cleared); + return this->implementation ()->cancel_wakeup (handle, + masks_to_be_cleared); } @@ -309,21 +309,21 @@ ACE_Reactor::notify (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, ACE_Time_Value *tv) { - return this->implementation_->notify (event_handler, - mask, - tv); + return this->implementation ()->notify (event_handler, + mask, + tv); } ACE_INLINE void ACE_Reactor::max_notify_iterations (int iterations) { - this->implementation_->max_notify_iterations (iterations); + this->implementation ()->max_notify_iterations (iterations); } ACE_INLINE int ACE_Reactor::max_notify_iterations (void) { - return this->implementation_->max_notify_iterations (); + return this->implementation ()->max_notify_iterations (); } ACE_INLINE int @@ -331,61 +331,61 @@ ACE_Reactor::handler (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Event_Handler **event_handler) { - return this->implementation_->handler (handle, - mask, - event_handler); + return this->implementation ()->handler (handle, + mask, + event_handler); } ACE_INLINE int ACE_Reactor::handler (int signum, ACE_Event_Handler **event_handler) { - return this->implementation_->handler (signum, - event_handler); + return this->implementation ()->handler (signum, + event_handler); } ACE_INLINE int ACE_Reactor::initialized (void) { - return this->implementation_->initialized (); + return this->implementation ()->initialized (); } ACE_INLINE ACE_Lock & ACE_Reactor::lock (void) { - return this->implementation_->lock (); + return this->implementation ()->lock (); } ACE_INLINE void ACE_Reactor::wakeup_all_threads (void) { - this->implementation_->wakeup_all_threads (); + this->implementation ()->wakeup_all_threads (); } ACE_INLINE int ACE_Reactor::owner (ACE_thread_t new_owner, ACE_thread_t *old_owner) { - return this->implementation_->owner (new_owner, - old_owner); + return this->implementation ()->owner (new_owner, + old_owner); } ACE_INLINE int ACE_Reactor::owner (ACE_thread_t *owner) { - return this->implementation_->owner (owner); + return this->implementation ()->owner (owner); } ACE_INLINE void ACE_Reactor::requeue_position (int position) { - this->implementation_->requeue_position (position); + this->implementation ()->requeue_position (position); } ACE_INLINE int ACE_Reactor::requeue_position (void) { - return this->implementation_->requeue_position (); + return this->implementation ()->requeue_position (); } @@ -394,9 +394,9 @@ ACE_Reactor::mask_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, int ops) { - return this->implementation_->mask_ops (event_handler, - mask, - ops); + return this->implementation ()->mask_ops (event_handler, + mask, + ops); } ACE_INLINE int @@ -404,9 +404,9 @@ ACE_Reactor::mask_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops) { - return this->implementation_->mask_ops (handle, - mask, - ops); + return this->implementation ()->mask_ops (handle, + mask, + ops); } ACE_INLINE int @@ -414,9 +414,9 @@ ACE_Reactor::ready_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, int ops) { - return this->implementation_->ready_ops (event_handler, - mask, - ops); + return this->implementation ()->ready_ops (event_handler, + mask, + ops); } ACE_INLINE int @@ -424,13 +424,25 @@ ACE_Reactor::ready_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops) { - return this->implementation_->ready_ops (handle, - mask, - ops); + return this->implementation ()->ready_ops (handle, + mask, + ops); } ACE_INLINE size_t ACE_Reactor::size (void) { - return this->implementation_->size (); + return this->implementation ()->size (); +} + +ACE_INLINE ACE_Reactor_Impl * +ACE_Reactor::implementation (void) +{ + return this->implementation_; +} + +ACE_INLINE void +ACE_Reactor::implementation (ACE_Reactor_Impl *impl) +{ + this->implementation_ = impl; } diff --git a/ace/SOCK_Acceptor.cpp b/ace/SOCK_Acceptor.cpp index 85322f5513c..dcf00d7d2bf 100644 --- a/ace/SOCK_Acceptor.cpp +++ b/ace/SOCK_Acceptor.cpp @@ -22,11 +22,19 @@ ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (void) // General purpose routine for accepting new connections. int -ACE_SOCK_Acceptor::accept (ACE_SOCK_Stream &new_stream, ACE_Addr *remote_addr, - ACE_Time_Value *timeout, int restart) const +ACE_SOCK_Acceptor::accept (ACE_SOCK_Stream &new_stream, + ACE_Addr *remote_addr, + ACE_Time_Value *timeout, + int restart, + int reset_new_handle) const { ACE_TRACE ("ACE_SOCK_Acceptor::accept"); - ACE_HANDLE new_handle = this->shared_accept (remote_addr, timeout, restart); + + ACE_HANDLE new_handle = + this->shared_accept (remote_addr, + timeout, + restart, + reset_new_handle); new_stream.set_handle (new_handle); return new_handle == ACE_INVALID_HANDLE ? -1 : 0; } @@ -87,9 +95,12 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap, ACE_HANDLE ACE_SOCK_Acceptor::shared_accept (ACE_Addr *remote_addr, ACE_Time_Value *timeout, - int restart) const + int restart, + int reset_new_handle) const { ACE_TRACE ("ACE_SOCK_Acceptor::shared_accept"); + ACE_UNUSED_ARG (reset_new_handle); + sockaddr *addr = 0; int *len_ptr = 0; int len; @@ -113,14 +124,13 @@ ACE_SOCK_Acceptor::shared_accept (ACE_Addr *remote_addr, new_handle = ACE_OS::accept (this->get_handle (), addr, len_ptr); while (new_handle == ACE_INVALID_HANDLE && restart && errno == EINTR); -#if 0 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - // Reset the event association inherited by the new handle - ::WSAEventSelect ((SOCKET) new_handle, - NULL, - 0); + if (reset_new_handle) + // Reset the event association inherited by the new handle + ::WSAEventSelect ((SOCKET) new_handle, + NULL, + 0); #endif /* ACE_WIN32 */ -#endif /* 0 */ // Reset the size of the addr (really only necessary for the // UNIX domain sockets). diff --git a/ace/SOCK_Acceptor.h b/ace/SOCK_Acceptor.h index fed78c498ab..a57164e46a5 100644 --- a/ace/SOCK_Acceptor.h +++ b/ace/SOCK_Acceptor.h @@ -47,7 +47,8 @@ public: int accept (ACE_SOCK_Stream &new_stream, ACE_Addr *remote_addr = 0, ACE_Time_Value *timeout = 0, - int restart = 1) const; + int restart = 1, + int reset_new_handle = 0) const; // Accept a new data transfer connection. A of 0 means // block forever, a of {0, 0} means poll. == 1 // means "restart if interrupted." @@ -65,7 +66,8 @@ public: protected: ACE_HANDLE shared_accept (ACE_Addr *remote_addr, ACE_Time_Value *, - int restart) const; + int restart, + int reset_new_handle) const; // Shared by both the ACE_LSOCK_Acceptor and ACE_SOCK_Acceptor. private: diff --git a/ace/SPIPE_Acceptor.cpp b/ace/SPIPE_Acceptor.cpp index 352070fdf6e..1101abf08a6 100644 --- a/ace/SPIPE_Acceptor.cpp +++ b/ace/SPIPE_Acceptor.cpp @@ -132,9 +132,12 @@ int ACE_SPIPE_Acceptor::accept (ACE_SPIPE_Stream &new_io, ACE_SPIPE_Addr *remote_addr, ACE_Time_Value *timeout, - int restart) + int restart, + int reset_new_handle) { ACE_TRACE ("ACE_SPIPE_Acceptor::accept"); + ACE_UNUSED_ARG (reset_new_handle); + #if defined (ACE_HAS_STREAM_PIPES) strrecvfd r_handle; diff --git a/ace/SPIPE_Acceptor.h b/ace/SPIPE_Acceptor.h index 84d1b2b42b7..c7771a6afa0 100644 --- a/ace/SPIPE_Acceptor.h +++ b/ace/SPIPE_Acceptor.h @@ -58,7 +58,8 @@ public: int accept (ACE_SPIPE_Stream &ipc_sap_spipe, ACE_SPIPE_Addr *remote_addr = 0, ACE_Time_Value *timeout = 0, - int restart = 1); + int restart = 1, + int reset_new_handle = 0); // Accept a new data transfer connection. A of 0 means // block forever, a of {0, 0} means poll. == 1 // means "restart if interrupted." diff --git a/ace/Service_Manager.cpp b/ace/Service_Manager.cpp index 6c1df9b23c5..3fdf1b5eb73 100644 --- a/ace/Service_Manager.cpp +++ b/ace/Service_Manager.cpp @@ -7,6 +7,7 @@ #include "ace/Service_Config.h" #include "ace/Service_Manager.h" #include "ace/Reactor.h" +#include "ace/WFMO_Reactor.h" #if !defined (__ACE_INLINE__) #include "ace/Service_Manager.i" @@ -205,7 +206,23 @@ ACE_Service_Manager::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_Service_Manager::handle_input"); - if (this->acceptor_.accept (this->client_stream_) == -1) + int reset_new_handle = 0; +#if defined (ACE_WIN32) + // Try to find out if the implementation of the reactor that we are + // using is the WFMO_Reactor. If so we need to reset the event + // association for the newly created handle. This is because the + // newly created handle will inherit the properties of the listen + // handle, including its event associations. + if (dynamic_cast (ACE_Reactor::instance ()->implementation ())) + reset_new_handle = 1; +#endif /* ACE_WIN32 */ + + if (this->acceptor_.accept (this->client_stream_, // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ) == -1) return -1; if (this->debug_) diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp index 963813cef7a..ab9ae5c07d0 100644 --- a/ace/Strategies_T.cpp +++ b/ace/Strategies_T.cpp @@ -7,6 +7,7 @@ #define ACE_BUILD_DLL #include "ace/Strategies_T.h" #include "ace/Service_Types.h" +#include "ace/WFMO_Reactor.h" ACE_ALLOC_HOOK_DEFINE(ACE_Singleton_Strategy) @@ -391,8 +392,11 @@ ACE_Thread_Strategy::activate_svc_handler (SVC_HANDLER *svc_handler ACE_ALLOC_HOOK_DEFINE(ACE_Accept_Strategy) template -ACE_Accept_Strategy::ACE_Accept_Strategy - (const ACE_PEER_ACCEPTOR_ADDR &local_addr, int restart) +ACE_Accept_Strategy::ACE_Accept_Strategy + (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + int restart, + ACE_Reactor *reactor) + : reactor_ (reactor) { ACE_TRACE ("ACE_Accept_Strategy::ACE_Accept_Strategy"); @@ -414,7 +418,8 @@ ACE_Accept_Strategy::dump (void) const } template -ACE_Accept_Strategy::ACE_Accept_Strategy (void) +ACE_Accept_Strategy::ACE_Accept_Strategy (ACE_Reactor *reactor) + : reactor_ (reactor) { ACE_TRACE ("ACE_Accept_Strategy::ACE_Accept_Strategy"); } @@ -425,9 +430,26 @@ ACE_Accept_Strategy::accept_svc_handler { ACE_TRACE ("ACE_Accept_Strategy::accept_svc_handler"); - if (this->acceptor_.accept (svc_handler->peer ()) == -1) + int reset_new_handle = 0; +#if defined (ACE_WIN32) + // Try to find out if the implementation of the reactor that we are + // using is the WFMO_Reactor. If so we need to reset the event + // association for the newly created handle. This is because the + // newly created handle will inherit the properties of the listen + // handle, including its event associations. + if (dynamic_cast (this->reactor_->implementation ())) + reset_new_handle = 1; +#endif /* ACE_WIN32 */ + + if (this->acceptor_.accept (svc_handler->peer (), // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ) == -1) { - svc_handler->close (0); + // Close down handler to avoid memory leaks. + svc_handler->close (0); return -1; } else diff --git a/ace/Strategies_T.h b/ace/Strategies_T.h index 663f3898e06..93d3f187068 100644 --- a/ace/Strategies_T.h +++ b/ace/Strategies_T.h @@ -18,6 +18,7 @@ #define ACE_STRATEGIES_T_H #include "ace/Service_Config.h" +#include "ace/Reactor.h" #include "ace/Synch_Options.h" #include "ace/Hash_Map_Manager.h" @@ -370,11 +371,12 @@ class ACE_Accept_Strategy { public: // = Initialization and termination methods. - ACE_Accept_Strategy (void); + ACE_Accept_Strategy (ACE_Reactor *reactor = ACE_Reactor::instance ()); // Default constructor. ACE_Accept_Strategy (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - int restart = 0); + int restart = 0, + ACE_Reactor *reactor = ACE_Reactor::instance ()); // Initialize the with . virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, @@ -403,6 +405,9 @@ public: protected: ACE_PEER_ACCEPTOR acceptor_; // Factory that establishes connections passively. + + ACE_Reactor *reactor_; + // Pointer to the reactor used by the Acceptor. }; template diff --git a/ace/TLI_Acceptor.cpp b/ace/TLI_Acceptor.cpp index 5271bcc1ac7..4e979b6075f 100644 --- a/ace/TLI_Acceptor.cpp +++ b/ace/TLI_Acceptor.cpp @@ -385,11 +385,14 @@ ACE_TLI_Acceptor::accept (ACE_TLI_Stream &new_tli_sap, ACE_Addr *remote_addr, ACE_Time_Value *timeout, int restart, + int reset_new_handle, int rwf, netbuf *udata, netbuf *opt) { ACE_TRACE ("ACE_TLI_Acceptor::accept"); + ACE_UNUSED_ARG (reset_new_handle); + ACE_TLI_Request *req = 0; int res = 0; diff --git a/ace/TLI_Acceptor.h b/ace/TLI_Acceptor.h index af795234662..355d8079c66 100644 --- a/ace/TLI_Acceptor.h +++ b/ace/TLI_Acceptor.h @@ -70,6 +70,7 @@ public: ACE_Addr *remote_addr = 0, ACE_Time_Value *timeout = 0, int restart = 1, + int reset_new_handle = 0, int rwflag = 1, netbuf *udata = 0, netbuf *opt = 0); diff --git a/ace/UPIPE_Acceptor.cpp b/ace/UPIPE_Acceptor.cpp index 4350f73b96d..da3af168aaf 100644 --- a/ace/UPIPE_Acceptor.cpp +++ b/ace/UPIPE_Acceptor.cpp @@ -60,9 +60,12 @@ int ACE_UPIPE_Acceptor::accept (ACE_UPIPE_Stream &new_stream, ACE_UPIPE_Addr *remote_addr, ACE_Time_Value *timeout, - int restart) + int restart, + int reset_new_handle) { ACE_TRACE ("ACE_UPIPE_Acceptor::accept"); + ACE_UNUSED_ARG (reset_new_handle); + ACE_SPIPE_Stream new_io; if (this->ACE_SPIPE_Acceptor::accept (new_io, remote_addr, diff --git a/ace/UPIPE_Acceptor.h b/ace/UPIPE_Acceptor.h index b855285f76e..6e27aa476d7 100644 --- a/ace/UPIPE_Acceptor.h +++ b/ace/UPIPE_Acceptor.h @@ -57,7 +57,8 @@ public: int accept (ACE_UPIPE_Stream &server_stream, ACE_UPIPE_Addr *remote_addr = 0, ACE_Time_Value *timeout = 0, - int restart = 1); + int restart = 1, + int reset_new_handle = 0); // Accept a new data transfer connection. A of 0 means // block forever, a of {0, 0} means poll. == 1 // means "restart if interrupted." -- cgit v1.2.1