From d805026a545fe037a9902d58079cb10de4fe25e0 Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Mon, 23 May 2011 10:33:45 +0300 Subject: [PATCH] more messages for error cases Signed-off-by: Mika Laitio --- src/plpbus/OrbServerImpl.cc | 104 ++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 41 deletions(-) diff --git a/src/plpbus/OrbServerImpl.cc b/src/plpbus/OrbServerImpl.cc index 9a48aba..931c6cf 100644 --- a/src/plpbus/OrbServerImpl.cc +++ b/src/plpbus/OrbServerImpl.cc @@ -177,7 +177,13 @@ int OrbServerImpl::init() { _orb = CORBA::ORB_init(argc, argv); if (_orb != NULL) { _poa = create_poa(_orb); - retVal = 0; + if (CORBA::is_nil(_poa) == false) { + retVal = 0; + log_info("init success\n"); + } + else { + log_info("init failed\n"); + } } else { log_error("init() failed\n"); @@ -225,8 +231,10 @@ PortableServer::POA_var OrbServerImpl::create_poa(CORBA::ORB_var orb) { PortableServer::POA_var rootpoa; ret_val = NULL; + log_debug("started"); poa_obj = orb->resolve_initial_references(CONST_ROOT_POA_NAME); if (poa_obj != NULL) { + log_debug("received initial reference to %s\n", CONST_ROOT_POA_NAME); rootpoa = PortableServer::POA::_narrow(poa_obj); if (rootpoa != NULL) { poa_man = rootpoa->the_POAManager(); @@ -236,14 +244,26 @@ PortableServer::POA_var OrbServerImpl::create_poa(CORBA::ORB_var orb) { policy_list.length(1); policyVal <<= BiDirPolicy::BOTH; policy_list[0] = orb->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, policyVal); - ret_val = rootpoa->create_POA(CONST_ROOT_POA_BIDIR_POLICY_NAME, + ret_val = rootpoa->create_POA(CONST_ROOT_POA_BIDIR_POLICY_NAME, poa_man, policy_list); + if (CORBA::is_nil(ret_val) == false) { + log_info("Created root poa %s\n", CONST_ROOT_POA_NAME); + } + else { + log_error("Failed to create RootPOA %s\n", CONST_ROOT_POA_NAME); + } + } + else { + log_error("Failed to create RootPOA, could not create POAManager for the root poa %s\n", CONST_ROOT_POA_NAME); } } + else { + log_error("Failed to create RootPOA, could not narrow root poa: %s\n", CONST_ROOT_POA_NAME); + } } else { - log_error("Failed to create RootPOA.\n"); + log_error("Failed to create RootPOA, could not resolve initial reference to %s.\n", CONST_ROOT_POA_NAME); } return ret_val; } @@ -261,42 +281,44 @@ CosNaming::NamingContext_var OrbServerImpl::get_service_naming_context(const cha try { // get nameservice reference log_debug("get_service_naming_context() 1\n"); - ns_obj = _orb->resolve_initial_references(CONST_NAME_SERVICE_NAME); - log_debug("get_service_naming_context() 2\n"); - // get name service context - ns_context = CosNaming::NamingContext::_narrow(ns_obj); - log_debug("get_service_naming_context() 3\n"); - if (CORBA::is_nil(ns_context) == false) { - context_data.length(1); - context_data[0].id = service_name_param; - context_data[0].kind = service_kind_param; - log_debug("get_service_naming_context() 4\n"); - try { - service_obj = ns_context->resolve(context_data); - } - catch(CosNaming::NamingContext::NotFound& ex) { - log_error("Failed to get context from name service for %s. Context does not yet exist, but will try to create.\n", service_name_param); - } - try { - log_debug("get_service_naming_context() 5\n"); - if (CORBA::is_nil(service_obj)) { - // not found, try to bind the new context to name service - log_debug("get_service_naming_context() 6\n"); - ret_val = ns_context->bind_new_context(context_data); - log_debug("get_service_naming_context() 7\n"); - if (CORBA::is_nil(ret_val) ) { - log_error("Failed to create new context to name service for %s.\n", service_name_param); - } + ns_obj = _orb->resolve_initial_references(CONST_NAME_SERVICE_NAME); + if (CORBA::is_nil(ns_obj) == false) { + log_debug("get_service_naming_context() 2\n"); + // get name service context + ns_context = CosNaming::NamingContext::_narrow(ns_obj); + log_debug("get_service_naming_context() 3\n"); + if (CORBA::is_nil(ns_context) == false) { + context_data.length(1); + context_data[0].id = service_name_param; + context_data[0].kind = service_kind_param; + log_debug("get_service_naming_context() 4\n"); + try { + service_obj = ns_context->resolve(context_data); } - else { - ret_val = CosNaming::NamingContext::_narrow(service_obj); - if (CORBA::is_nil(ret_val) ) { - log_error("Failed to get existing context from name service for %s, narrowing failed.\n", service_name_param); + catch(CosNaming::NamingContext::NotFound& ex) { + log_error("Failed to get context from name service for %s. Context does not yet exist, but will try to create.\n", service_name_param); + } + try { + log_debug("get_service_naming_context() 5\n"); + if (CORBA::is_nil(service_obj)) { + // not found, try to bind the new context to name service + log_debug("get_service_naming_context() 6\n"); + ret_val = ns_context->bind_new_context(context_data); + log_debug("get_service_naming_context() 7\n"); + if (CORBA::is_nil(ret_val) ) { + log_error("Failed to create new context to name service for %s.\n", service_name_param); + } + } + else { + ret_val = CosNaming::NamingContext::_narrow(service_obj); + if (CORBA::is_nil(ret_val) ) { + log_error("Failed to get existing context from name service for %s, narrowing failed.\n", service_name_param); + } } } - } - catch(CosNaming::NamingContext::AlreadyBound& ex) { - log_error("Failed to get context from name service for %s. Context with same name already exist.\n", service_name_param); + catch(CosNaming::NamingContext::AlreadyBound& ex) { + log_error("Failed to get context from name service for %s. Context with same name already exist.\n", service_name_param); + } } } } @@ -369,7 +391,7 @@ int OrbServerImpl::add_server_listener(IServerListener *listener_param) int retVal; retVal = 0; - log_debug("register_request_received_callback() started\n"); + log_debug("started\n"); _listener = listener_param; return retVal; } @@ -381,18 +403,18 @@ int OrbServerImpl::is_shutdown_pending() { void OrbServerImpl::server_thread_closed() { bool send_signal; - log_debug("server_thread_closed() started\n"); + log_debug("started\n"); send_signal = false; server_thread_mutex.lock(); - log_debug("server_thread_closed(), server_thread_count: %d\n", _server_thread_count); + log_debug("server_thread_count: %d\n", _server_thread_count); _server_thread_count--; if (_server_thread_count == 0) { send_signal = true; } server_thread_mutex.unlock(); if (send_signal == true) { - log_debug("server_thread_closed(), sending signal\n"); + log_debug("sending signal\n"); server_thread_shutdown_signal.signal(); - log_debug("server_thread_closed(), signal send\n"); + log_debug("signal send\n"); } } -- 2.41.1