Merge pull request #2218 from jwillemsen/jwi-pthreadsigmask
[ACE_TAO.git] / TAO / tao / Messaging / Asynch_Timeout_Handler.cpp
blobaec430f35608f209f4c7c4d4cf7742d769d2e84f
1 // -*- C++ -*-
2 #include "tao/Messaging/Asynch_Timeout_Handler.h"
4 #include "tao/Messaging/Asynch_Reply_Dispatcher.h"
5 #include "tao/Transport_Mux_Strategy.h"
6 #include "ace/Reactor.h"
8 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
10 TAO_Asynch_Timeout_Handler::TAO_Asynch_Timeout_Handler (
11 ACE_Reactor *reactor)
12 : tms_ (0),
13 request_id_ (0),
14 reactor_ (reactor)
16 // Enable reference counting on the event handler.
17 this->reference_counting_policy ().value (
18 ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
21 long
22 TAO_Asynch_Timeout_Handler::schedule_timer (TAO_Transport_Mux_Strategy *tms,
23 CORBA::ULong request_id,
24 const ACE_Time_Value &max_wait_time)
26 // Remember them for later.
27 this->tms_ = tms;
28 this->request_id_ = request_id;
30 return this->reactor_->schedule_timer (this, // handler
31 0, // arg
32 max_wait_time);
35 int
36 TAO_Asynch_Timeout_Handler::handle_timeout (const ACE_Time_Value &,
37 const void *)
39 // Check if there was a reply dispatcher registered in the tms, if not
40 // the reply already got dispatched by another thread
41 if (this->tms_->reply_timed_out (this->request_id_) == 0)
43 if (TAO_debug_level >= 4)
45 TAOLIB_DEBUG ((LM_DEBUG,
46 ACE_TEXT ("TAO_Messaging (%P|%t) - Asynch_Timeout_Handler")
47 ACE_TEXT ("::handle_timeout, request [%d] timed out\n"),
48 this->request_id_));
51 else
53 if (TAO_debug_level >= 1)
55 TAOLIB_ERROR ((LM_ERROR,
56 ACE_TEXT ("TAO_Messaging (%P|%t) - Asynch_Timeout_Handler")
57 ACE_TEXT ("::handle_timeout, unable to dispatch timed out request [%d]\n"),
58 this->request_id_));
62 // reset any possible timeout errno
63 errno = 0;
65 // we are unregistered anyway
66 return 0;
69 void
70 TAO_Asynch_Timeout_Handler::cancel ()
72 // The tms_ is only set if we got scheduled.
73 if (this->tms_)
75 this->reactor_->cancel_timer (this);
79 TAO_END_VERSIONED_NAMESPACE_DECL