diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2000-06-26 19:47:57 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2000-06-26 19:47:57 +0000 |
commit | 7b21238b2251f04fd4bcd3a525b9b5b639860e49 (patch) | |
tree | cc96bd89b85fb31a9520732c442def9760a089e0 /TAO/tao/Acceptor_Registry.cpp | |
parent | c98304e9c8e2554f42517a3a8a5c06a9a17edf1d (diff) | |
download | ATCD-7b21238b2251f04fd4bcd3a525b9b5b639860e49.tar.gz |
ChangeLogTag:Mon Jun 26 12:44:40 2000 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'TAO/tao/Acceptor_Registry.cpp')
-rw-r--r-- | TAO/tao/Acceptor_Registry.cpp | 319 |
1 files changed, 193 insertions, 126 deletions
diff --git a/TAO/tao/Acceptor_Registry.cpp b/TAO/tao/Acceptor_Registry.cpp index c00dd7c0ba7..5c592a0ce40 100644 --- a/TAO/tao/Acceptor_Registry.cpp +++ b/TAO/tao/Acceptor_Registry.cpp @@ -145,8 +145,6 @@ TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, ACE_CHECK_RETURN (-1); } - ACE_Auto_Basic_Array_Ptr <char> addr_str; - for (ACE_CString *endpoint = 0; endpoints.next (endpoint) != 0; endpoints.advance ()) @@ -166,10 +164,10 @@ TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, iop.c_str ())); ACE_THROW_RETURN (CORBA::BAD_PARAM ( - CORBA_SystemException::_tao_minor_code ( - TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, - EINVAL), - CORBA::COMPLETED_NO), + CORBA_SystemException::_tao_minor_code ( + TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, + EINVAL), + CORBA::COMPLETED_NO), -1); } @@ -193,124 +191,22 @@ TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, factory != end; ++factory) { + if ((*factory)->factory ()->match_prefix (prefix)) { - found = 1; // A usable protocol was found. - // increment slot past the "://" (i.e. add 3) ACE_CString addrs = iop.substring (slot + 3); - ACE_CString options; - - int options_index = - addrs.find ((*factory)->factory ()->options_delimiter ()); - - if (options_index == ACE_static_cast (int, - addrs.length () - 1)) - { - // Get rid of trailing option delimiter. - addrs = addrs.substring (0, addrs.length () - 1); - } - else if (options_index != ACE_CString::npos) - { - options = addrs.substring (options_index + 1); - - addrs = addrs.substring (0, options_index); - } - - // Check for the presence of addresses. - if (addrs.length () == 0) - { - // Protocol was specified without an endpoint. - // All TAO pluggable protocols are expected to have - // the ability to create a default endpoint. - if (this->open_default (orb_core, - factory, - ((options.length () == 0) - ? 0 : options.c_str ())) == 0) - continue; - else - ACE_THROW_RETURN (CORBA::INTERNAL ( - CORBA_SystemException::_tao_minor_code ( - TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, - 0), - CORBA::COMPLETED_NO), - -1); - } - - char *last_addr = 0; - addr_str.reset (addrs.rep ()); - - // Iterate over the addrs specified in the endpoint. - for (char *astr = ACE_OS::strtok_r (addr_str.get (), - ",", - &last_addr); - astr != 0 ; - astr = ACE_OS::strtok_r (0, - ",", - &last_addr)) - { - ACE_CString address (astr); - - TAO_Acceptor *acceptor = - (*factory)->factory ()->make_acceptor (); - if (acceptor != 0) - { - // Check if an "N.n@" version prefix was - // specified. - int major = -1; - int minor = -1; - if (isdigit (address[0]) - && address[1] == '.' - && isdigit (address[2]) - && address[3] == '@') - { - major = address[0] - '0'; - minor = address[2] - '0'; - address = address.substring (4); - } - - if (acceptor->open (orb_core, - major, minor, - address.c_str (), - ((options.length () == 0) - ? 0 : options.c_str ())) == -1) - { - delete acceptor; - - if (TAO_debug_level > 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) unable to open acceptor ") - ACE_TEXT ("for <%s>%p\n"), - iop.c_str (),"")); - - ACE_THROW_RETURN (CORBA::BAD_PARAM ( - CORBA_SystemException::_tao_minor_code ( - TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, - EINVAL), - CORBA::COMPLETED_NO), - -1); - } - - // add acceptor to list - this->acceptors_[this->size_++] = acceptor; - } - else - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) unable to create ") - ACE_TEXT ("an acceptor for <%s>.\n"), - iop.c_str ())); - - ACE_THROW_RETURN (CORBA::NO_MEMORY ( - CORBA_SystemException::_tao_minor_code ( - TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, - ENOMEM), - CORBA::COMPLETED_NO), - -1); - } - } + int result = this->open_i (orb_core, + addrs, + factory, + ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + if (result != 0) + return -1; + + found = 1; // A usable protocol was found. } else continue; @@ -319,14 +215,15 @@ TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, if (found == 0) { ACE_ERROR ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) no usable transport protocol ") + ACE_TEXT ("TAO (%P|%t) ") + ACE_TEXT ("no usable transport protocol ") ACE_TEXT ("was found.\n"))); ACE_THROW_RETURN (CORBA::BAD_PARAM ( - CORBA_SystemException::_tao_minor_code ( - TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, - EINVAL), - CORBA::COMPLETED_NO), + CORBA_SystemException::_tao_minor_code ( + TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, + EINVAL), + CORBA::COMPLETED_NO), -1); } } @@ -368,7 +265,11 @@ int TAO_Acceptor_Registry::open_default (TAO_ORB_Core *orb_core, // up if the server crashes. if (!(*i)->factory ()->requires_explicit_endpoint ()) { - if (this->open_default (orb_core, i, options) != 0) + if (this->open_default (orb_core, + -1, /* use default major version */ + -1, /* use default minor version */ + i, + options) != 0) return -1; opened_endpoint = 1; @@ -396,6 +297,8 @@ int TAO_Acceptor_Registry::open_default (TAO_ORB_Core *orb_core, // the indicated protocol. int TAO_Acceptor_Registry::open_default (TAO_ORB_Core *orb_core, + int major, + int minor, TAO_ProtocolFactorySetItor &factory, const char *options) { @@ -418,7 +321,10 @@ TAO_Acceptor_Registry::open_default (TAO_ORB_Core *orb_core, } // Initialize the acceptor to listen on a default endpoint. - if (acceptor->open_default (orb_core, options) == -1) + if (acceptor->open_default (orb_core, + major, + minor, + options) == -1) { delete acceptor; @@ -458,6 +364,167 @@ TAO_Acceptor_Registry::close_all (void) return 0; } +void +TAO_Acceptor_Registry::extract_endpoint_options (ACE_CString &addrs, + ACE_CString &options, + TAO_Protocol_Factory *factory) +{ + int options_index = + addrs.find (factory->options_delimiter ()); + + if (options_index == ACE_static_cast (int, + addrs.length () - 1)) + { + // Get rid of trailing option delimiter. + addrs = addrs.substring (0, addrs.length () - 1); + } + else if (options_index != ACE_CString::npos) + { + options = addrs.substring (options_index + 1); + + addrs = addrs.substring (0, options_index); + } +} + +void +TAO_Acceptor_Registry::extract_endpoint_version (ACE_CString &address, + int &major, + int &minor) +{ + // Check if an "N.n@" version prefix was + // specified. + major = -1; + minor = -1; + if (isdigit (address[0]) + && address[1] == '.' + && isdigit (address[2]) + && address[3] == '@') + { + major = address[0] - '0'; + minor = address[2] - '0'; + address = address.substring (4); + } +} + +int +TAO_Acceptor_Registry::open_i (TAO_ORB_Core *orb_core, + ACE_CString &addrs, + TAO_ProtocolFactorySetItor &factory, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_CString options_tmp; + this->extract_endpoint_options (addrs, + options_tmp, + (*factory)->factory ()); + + const char *options = 0; + if (options_tmp.length () > 0) + options = options_tmp.c_str (); + + char *last_addr = 0; + ACE_Auto_Basic_Array_Ptr <char> addr_str (addrs.rep ()); + + char *astr = ACE_OS::strtok_r (addr_str.get (), + ",", + &last_addr); + if (astr == 0) + astr = ""; + + // Iterate over the addrs specified in the endpoint. + + for ( ; + astr != 0 ; + astr = ACE_OS::strtok_r (0, + ",", + &last_addr)) + { + ACE_CString address (astr); + + TAO_Acceptor *acceptor = + (*factory)->factory ()->make_acceptor (); + if (acceptor != 0) + { + // Extract the desired endpoint/protocol version if one + // exists. + int major = -1; + int minor = -1; + this->extract_endpoint_version (address, + major, + minor); + + // Check for existence of endpoint. + if (address.length () == 0) + { + // Protocol prefix was specified without any endpoints. + // All TAO pluggable protocols are expected to have the + // ability to create a default endpoint. + if (this->open_default (orb_core, + major, + minor, + factory, + options) == 0) + continue; + + // Could not open a default endpoint, nor an explicit + // one. + else + ACE_THROW_RETURN (CORBA::INTERNAL ( + CORBA_SystemException::_tao_minor_code ( + TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, + 0), + CORBA::COMPLETED_NO), + -1); + } + + // An explicit endpoint was provided. + else if (acceptor->open (orb_core, + major, + minor, + address.c_str (), + options) == -1) + { + delete acceptor; + + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) ") + ACE_TEXT ("unable to open acceptor ") + ACE_TEXT ("for <%s>%p\n"), + address.c_str (), + "")); + + ACE_THROW_RETURN (CORBA::BAD_PARAM ( + CORBA_SystemException::_tao_minor_code ( + TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, + EINVAL), + CORBA::COMPLETED_NO), + -1); + } + + // add acceptor to list + this->acceptors_[this->size_++] = acceptor; + } + else + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) unable to create ") + ACE_TEXT ("an acceptor for <%s>.\n"), + address.c_str ())); + + ACE_THROW_RETURN (CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE, + ENOMEM), + CORBA::COMPLETED_NO), + -1); + } + } + + return 0; +} + + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) |