Invocation_Endpoint_Selectors.cpp

Go to the documentation of this file.
00001 //$Id: Invocation_Endpoint_Selectors.cpp 80108 2007-11-27 11:22:38Z 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 80108 2007-11-27 11:22:38Z 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   while (r->stub ()->next_profile_retry () != 0);
00076 
00077   // If we get here, we completely failed to find an endpoint
00078   // that we know how to use. We used to throw an exception
00079   // but that would prevent any request interception points
00080   // being called. They may know how to fix the problem so
00081   // we wait to throw the exception in
00082   // Synch_Twoway_Invocation::remote_twoway and
00083   // Synch_Oneway_Invocation::remote_oneway instead.
00084 }
00085 
00086 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7