Invocation_Endpoint_Selectors.cpp

Go to the documentation of this file.
00001 //$Id: Invocation_Endpoint_Selectors.cpp 76932 2007-02-06 16:34:57Z johnnyw $
00002 #include "tao/Invocation_Endpoint_Selectors.h"
00003 #include "tao/Stub.h"
00004 #include "tao/Profile.h"
00005 #include "tao/ORB_Core.h"
00006 #include "tao/IIOP_Endpoint.h"
00007 #include "tao/Base_Transport_Property.h"
00008 #include "tao/Profile_Transport_Resolver.h"
00009 #include "tao/ORB_Constants.h"
00010 #include "tao/SystemException.h"
00011 
00012 ACE_RCSID (tao,
00013            Invocation_Endpoint_Selectors,
00014            "$Id: Invocation_Endpoint_Selectors.cpp 76932 2007-02-06 16:34:57Z johnnyw $")
00015 
00016 
00017   TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 TAO_Invocation_Endpoint_Selector::~TAO_Invocation_Endpoint_Selector (void)
00020 {
00021 }
00022 
00023 // ****************************************************************
00024 
00025 TAO_Default_Endpoint_Selector::~TAO_Default_Endpoint_Selector (void)
00026 {
00027 }
00028 
00029 void
00030 TAO_Default_Endpoint_Selector::select_endpoint (TAO::Profile_Transport_Resolver *r,
00031                                                 ACE_Time_Value *max_wait_time)
00032 {
00033   do
00034     {
00035       r->profile (r->stub ()->profile_in_use ());
00036 
00037       // Check whether we need to do a blocked wait or we have a
00038       // non-blocked wait and we support that.  If this is not the
00039       // case we can't use this profile so try the next.
00040       if (r->blocked_connect () ||
00041           (!r->blocked_connect () &&
00042            r->profile ()->supports_non_blocking_oneways ()))
00043         {
00044           if (r->profile ()->endpoint_count () > 1 &&
00045               r->use_parallel_connect())
00046             {
00047               TAO_Endpoint *ep = r->profile ()->endpoint ();
00048 
00049               TAO_Base_Transport_Property desc (ep);
00050 
00051               // Check if the connect has completed.
00052               if (r->try_parallel_connect (&desc, max_wait_time))
00053                 return;
00054               // The default implementation of try_parallel_connect returns
00055               // a not supported errno. In this case, allow the ordinary
00056               // connection mechanism to be tried. OTOH, if the connection
00057               // attempt failed for some other reason, then abandon this
00058               // profile and try the next one in the list.
00059               else if (errno != ENOTSUP)
00060                 continue;
00061             }
00062 
00063           for (TAO_Endpoint *ep = r->profile ()->first_filtered_endpoint ();
00064                ep != 0;
00065                ep = r->profile ()->next_filtered_endpoint (ep))
00066             {
00067               TAO_Base_Transport_Property desc (ep);
00068 
00069               // Check if the connect has completed.
00070               if (r->try_connect (&desc, max_wait_time))
00071                 return;
00072             }
00073 
00074         }
00075     }
00076   while (r->stub ()->next_profile_retry () != 0);
00077 
00078   // If we get here, we completely failed to find an endpoint selector
00079   // that we know how to use, so throw an exception.
00080   throw ::CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
00081 }
00082 
00083 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 13:07:33 2008 for TAO by doxygen 1.3.6