00001 #include "tao/Reactive_Connect_Strategy.h" 00002 #include "tao/Connection_Handler.h" 00003 #include "tao/ORB_Core.h" 00004 #include "tao/debug.h" 00005 #include "tao/Transport.h" 00006 #include "tao/LF_Multi_Event.h" 00007 00008 #include "ace/Synch_Options.h" 00009 00010 ACE_RCSID(tao, 00011 Reactive_Connect_Strategy, 00012 "$Id: Reactive_Connect_Strategy.cpp 78619 2007-06-28 00:06:10Z sowayaa $") 00013 00014 00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00016 00017 TAO_Reactive_Connect_Strategy::TAO_Reactive_Connect_Strategy ( 00018 TAO_ORB_Core *orb_core) 00019 : TAO_Connect_Strategy (orb_core) 00020 { 00021 } 00022 00023 TAO_Reactive_Connect_Strategy::~TAO_Reactive_Connect_Strategy (void) 00024 { 00025 } 00026 00027 void 00028 TAO_Reactive_Connect_Strategy::synch_options (ACE_Time_Value *timeout, 00029 ACE_Synch_Options &options) 00030 { 00031 if (timeout != 0) 00032 { 00033 options.set (ACE_Synch_Options::USE_REACTOR, 00034 *timeout); 00035 } 00036 else 00037 { 00038 // Making it sure it is blocking. 00039 options.set (ACE_Synch_Options::USE_REACTOR, 00040 ACE_Time_Value::zero); 00041 } 00042 } 00043 00044 int 00045 TAO_Reactive_Connect_Strategy::wait_i (TAO_LF_Event *ev, 00046 TAO_Transport *, 00047 ACE_Time_Value * max_wait_time) 00048 { 00049 int result = 0; 00050 if (ev == 0) 00051 return -1; 00052 00053 if (TAO_debug_level > 2) 00054 { 00055 //FUZZ: disable check_for_lack_ACE_OS 00056 ACE_DEBUG ((LM_DEBUG, 00057 ACE_TEXT ("TAO (%P|%t) - Waiting in the Reactor for ") 00058 ACE_TEXT ("connection completion - wait ()\n"))); 00059 //FUZZ: enable check_for_lack_ACE_OS 00060 } 00061 00062 try 00063 { 00064 while (ev->keep_waiting ()) 00065 { 00066 result = 00067 this->orb_core_->run (max_wait_time, 1); 00068 00069 // Did we timeout? If so, stop running the loop. 00070 if (result == 0 && 00071 max_wait_time != 0 && 00072 *max_wait_time == ACE_Time_Value::zero) 00073 { 00074 errno = ETIME; 00075 result = -1; 00076 break; 00077 } 00078 00079 // Other errors? If so, stop running the loop. 00080 if (result == -1) 00081 break; 00082 } 00083 } 00084 catch (const ::CORBA::Exception&) 00085 { 00086 result = -1; 00087 } 00088 00089 // Set the result. 00090 if (result != -1 && ev->error_detected ()) 00091 { 00092 result = -1; 00093 } 00094 00095 return result; 00096 } 00097 00098 TAO_END_VERSIONED_NAMESPACE_DECL