]> pilppa.com Git - libplpbus.git/commitdiff
cleanups
authorMika Laitio <lamikr@pilppa.org>
Thu, 16 Jun 2011 17:28:33 +0000 (20:28 +0300)
committerMika Laitio <lamikr@pilppa.org>
Thu, 16 Jun 2011 17:28:33 +0000 (20:28 +0300)
src/plpbus/BusClient.cc
src/plpbus/BusMessage.cc
src/plpbus/BusMessageInternal.cc
src/plpbus/BusServer.cc
src/plpbus/OrbServerImpl.cc
src/plpbus/OrbServerImpl.hh
src/plpbus/ServerEventThread.cc

index 2ab2a2d6975676889197fd7bad4fdd7263968551..5c20d5d9a29055d4eaff3be39efa438030500f3c 100644 (file)
@@ -99,7 +99,7 @@ int BusClient::init(const char *server_name) {
                if (CORBA::is_nil(server_obj) == false) {
                        _server         = plpbus_orb::OrbServer::_narrow(server_obj);
                        if (CORBA::is_nil(_server) == false) {
-                               log_info("CORBA service found: %s", server_name);
+                               log_info("CORBA service found: %s\n", server_name);
                                ret_val = PLP_OK;
                        }
                }
@@ -114,7 +114,7 @@ int BusClient::init(const char *server_name) {
 }
 
 int BusClient::add_client_listener(IClientListener *listener_param) {
-       log_debug("add_client_listener() started\n");
+       log_debug("started\n");
        if (_poa == NULL) {
                OrbClientImpl                   *client_cb;
                PortableServer::ObjectId_var    oid;
@@ -126,7 +126,7 @@ int BusClient::add_client_listener(IClientListener *listener_param) {
                client_cb->_remove_ref();
                _server->add_event_listener(_client, "event_message", CONST_DEFAULT_EVENT_INTERVAL);
        }
-       log_debug("add_client_listener() done\n");
+       log_debug("done\n");
        return 0;
 }
 
@@ -198,7 +198,7 @@ PortableServer::POA_var BusClient::create_poa(CORBA::ORB_var orb) {
                }
        }
        else {
-               cerr << "Failed to create RootPOA." << endl;
+               log_error("Failed to create RootPOA\n");
        }
        return ret_val;
 }
@@ -218,16 +218,16 @@ CosNaming::NamingContext_var BusClient::get_name_service_context(CORBA::ORB_var
        }
        catch (CORBA::ORB::InvalidName&) {
                // This should not happen!
-               cerr << "Could not find name service." << endl;
+               log_error("Could not find name service.\n");
        }
        catch(CORBA::TRANSIENT& ex) {
-               cerr << "Could not find name service, verify that name service is running. " << endl;
+               log_error("Could not find name service, verify that name service is running.\n");
        }
        catch (CORBA::NO_RESOURCES&) {
-               cerr << "Could not find name service, verify that name service is running. " << endl;
+               log_error("Could not find name service, verify that name service is running.\n");
        }
        catch(CORBA::SystemException& ex) {
-               cerr << "Could not find name service, unknown reason. " << endl;
+               log_error("Could not find name service, unknown reason.\n");
        }
        return ret_val;
 }
index 0b1d9015130f26dba13625edcbfcb77c7dd5f2d4..99d32a0f9ac9d958dd52a1f25bd317619b3a7abe 100644 (file)
@@ -43,7 +43,7 @@ BusMessage::~BusMessage() {
        long                    cnt;
        DataItemSequence        *seq;
 
-       log_debug("BusMessage DESTRUCTOR\n");
+       log_debug("\n");
        seq     = (DataItemSequence *)_dataItemSeq;
        if (seq != NULL) {
                cnt     = seq->length();
index be06076aec54ae6d7bc7a887bfd0fbb2e62b7f50..083fa5b2e571e2e71c77de41582bd1d236cbb935 100644 (file)
@@ -21,5 +21,5 @@ BusMessageInternal::BusMessageInternal(DataItemSequence seq_param) : BusMessage(
 }
 
 BusMessageInternal::~BusMessageInternal() {
-       log_debug("BusMessageInternal() DESTRUCTOR\n");
+       log_debug("\n");
 }
index 993c995a9723f97d8528fdac1a4265faec89bdec..e53023cf356ba24b26bb680255e776166c9788bc 100644 (file)
@@ -4,13 +4,11 @@
 using namespace std;
 using namespace plpbus;
 
-BusServer::BusServer()
-{
+BusServer::BusServer() {
        orbServer       = new OrbServerImpl();
 }
 
-BusServer::~BusServer()
-{
+BusServer::~BusServer() {
        cout << "BusServer() destroyed." << endl;
 }
 
@@ -24,8 +22,7 @@ int BusServer::init() {
        return retVal;
 }
 
-int BusServer::launch(const char *server_name)
-{
+int BusServer::launch(const char *server_name) {
        int             retVal;
        OrbServerImpl   *impl;
 
@@ -34,8 +31,7 @@ int BusServer::launch(const char *server_name)
        return retVal;
 }
 
-int BusServer::add_server_listener(IServerListener *listener_param)
-{
+int BusServer::add_server_listener(IServerListener *listener_param) {
        int             retVal;
        OrbServerImpl   *impl;
 
@@ -44,8 +40,7 @@ int BusServer::add_server_listener(IServerListener *listener_param)
        return retVal;
 }
 
-void BusServer::shutdown()
-{
+void BusServer::shutdown() {
        OrbServerImpl   *impl;
 
        impl    = (OrbServerImpl *)orbServer;
index 57dcac4f0d71fc283f5172c2a1d559662561fb98..0a037f26e23462ad1245b183d15a729d423defd1 100644 (file)
@@ -30,7 +30,7 @@ OrbServerImpl::OrbServerImpl()
 
 OrbServerImpl::~OrbServerImpl()
 {
-       log_info("OrbServerImpl destroyed.\n");
+       log_info("done\n");
 }
 
 void OrbServerImpl::send_message_and_request_response(OrbClient_ptr response_listener_param,
@@ -205,7 +205,7 @@ int OrbServerImpl::launch(const char *server_name)
        server_id       = _poa->activate_object(&server_impl);
        server_ref      = server_impl._this();
        //this->_remove_ref();
-       naming_cntx     = get_service_naming_context(CONST_CONTEXT_NAME__PLPBUS, CONST_CONTEXT_KIND__PLPBUS);
+       naming_cntx     = get_naming_service_context(CONST_CONTEXT_NAME__PLPBUS, CONST_CONTEXT_KIND__PLPBUS);
        if (naming_cntx != NULL) {
                ok_flg  = bind_naming_context_and_service(naming_cntx,
                                                        server_ref,
@@ -233,7 +233,7 @@ PortableServer::POA_var OrbServerImpl::create_poa(CORBA::ORB_var orb) {
        PortableServer::POA_var         rootpoa;
 
        ret_val = NULL;
-       log_debug("started");
+       log_debug("started\n");
        try {
                poa_obj = orb->resolve_initial_references(CONST_ROOT_POA_NAME);
                log_debug("received initial reference to %s\n", CONST_ROOT_POA_NAME);
@@ -266,7 +266,7 @@ PortableServer::POA_var OrbServerImpl::create_poa(CORBA::ORB_var orb) {
        return ret_val;
 }
 
-CosNaming::NamingContext_var OrbServerImpl::get_service_naming_context(const char *service_name_param,
+CosNaming::NamingContext_var OrbServerImpl::get_naming_service_context(const char *service_name_param,
                                                                const char *service_kind_param)
 {
        CosNaming::NamingContext_var    ret_val;
@@ -278,72 +278,65 @@ CosNaming::NamingContext_var OrbServerImpl::get_service_naming_context(const cha
        ret_val = NULL;
        try {
                // get nameservice reference
-               log_debug("1\n");
+               log_debug("started\n");
                ns_obj  = _orb->resolve_initial_references(CONST_NAME_SERVICE_NAME);
                if (CORBA::is_nil(ns_obj) == false) {
-                       log_debug("2\n");
-                       // get name service context
+                       // get naming service context
                        ns_cntx = CosNaming::NamingContext::_narrow(ns_obj);
-                       log_debug("3\n");
                        if (CORBA::is_nil(ns_cntx) == false) {
                                cntx_dta.length(1);
                                cntx_dta[0].id          = CORBA::string_dup(service_name_param);
                                cntx_dta[0].kind        = CORBA::string_dup(service_kind_param);
-                               log_debug("4\n");
                                try {
                                        service_obj     = ns_cntx->resolve(cntx_dta);
                                }
                                catch(CosNaming::NamingContext::NotFound& ex) {
-                                       log_error("Trying to create new name service context %s.\n", service_name_param);
+                                       log_error("Trying to create new naming service context %s.\n", service_name_param);
                                }
                                try {
-                                       log_debug("5\n");
                                        if (CORBA::is_nil(service_obj)) {
-                                               // not found, try to bind the new context to name service
-                                               log_debug("6\n");
+                                               // not found, try to bind new context from naming service
                                                ret_val = ns_cntx->bind_new_context(cntx_dta);
-                                               log_debug("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 {
-                                               log_debug("8\n");
                                                ret_val = CosNaming::NamingContext::_narrow(service_obj);
                                                if (CORBA::is_nil(ret_val) ) {
-                                                       log_error("Failed to get name service context for  %s, narrowing failed for resolved service context.\n", service_name_param);
+                                                       log_error("Failed to get naming service context for  %s, narrowing failed for resolved service context.\n", service_name_param);
                                                }
-                                               log_debug("9\n");
                                        }
                                }
                                catch(CosNaming::NamingContext::AlreadyBound& ex) {
-                                       log_error("Failed to get name service context for %s. Context with same name already exist.\n", service_name_param);
+                                       log_error("Failed to get naming service context for %s. Context with same name already exist.\n", service_name_param);
                                }
                        }
                        else {
-                               log_error("Failed to get name service context for %s. Could not narrow the name service.\n", service_name_param);
+                               log_error("Failed to get naming service context for %s. Could not narrow the name service.\n", service_name_param);
                        }
+                       //CORBA::release(ns_obj);
                }
                else {
-                       log_error("Failed to get name service context for %s. Could not get reference to name service.\n", service_name_param);
+                       log_error("Failed to get naming service context for %s. Could not get reference to name service.\n", service_name_param);
                }
        }
        catch (CORBA::ORB::InvalidName&) {
                // This should not happen!
-               log_error("Failed to get name service context for %s, name service does not exist.\n", service_name_param);
+               log_error("Failed to get naming service context for %s, name service does not exist.\n", service_name_param);
        }
        catch(CORBA::TRANSIENT& ex) {
-               log_error("Failed to get name service context for %s, verify that name service is running.\n", service_name_param);
+               log_error("Failed to get naming service context for %s, verify that name service is running.\n", service_name_param);
        }
        catch (CORBA::NO_RESOURCES&) {
-               log_error("Failed to get context from name service for %s, Name service is not running or has configuration problem.\n", service_name_param);
+               log_error("Failed to get context from name service for %s, Naming service is not running or has configuration problem.\n", service_name_param);
                log_error("Check-list:\n");
                log_error("If you have OMNIORB_CONFIG environment variable defined, verify that omniORB.cfg file exist in that location.\n");
                log_error("If you do not have OMNIORB_CONFIG environment variable defined, verify that you have /etc/omniORB.cfg file\n");
                log_error("Verify that InitRef line is defined in omniORB.cfg file.\n");
        }
        catch(CORBA::SystemException& ex) {
-               log_error("Failed to get name service context for %s, system error.\n", service_name_param);
+               log_error("Failed to get naming service context for %s, system error.\n", service_name_param);
        }
        log_debug("done\n");
        return ret_val;
index a73e7bfba849596d872da5d8eb6a73463825f559..ec270e8c7ab754fb33232ce0d80eea62d853e734 100644 (file)
@@ -43,8 +43,8 @@ namespace plpbus {
                        /**
                         * Gets naming context from the name service. If the naming context does not yet exist, create it.
                         */
-                       CosNaming::NamingContext_var get_service_naming_context(const char *leafcontext_name,
-                                                                       const char *leafcontext_kind);
+                       CosNaming::NamingContext_var get_naming_service_context(const char *service_name_param,
+                                                                       const char *service_kind_param);
                        /**
                         * Bind service to naming context.
                         * If service with same name has already been binded, replace the existing service with the new one.
index fadb9f5df43ddc4dd5e7bccb81ecc2e79f5d4cc3..9660597bd971cdfcf277b2e12ac92b5f8a872cc9 100644 (file)
@@ -16,10 +16,9 @@ using namespace std;
 using namespace plpbus;
 
 ServerEventThread::ServerEventThread(plpbus_orb::OrbClient_ptr client,
-       const char      *msg,
-       int             period,
-       OrbServerImpl   *server_obj)
-{
+                               const char      *msg,
+                               int             period,
+                               OrbServerImpl   *server_obj) {
        this->_orb_client       = plpbus_orb::OrbClient::_duplicate(client);
        this->_orb_msg          = msg;
        this->_interval         = period;
@@ -27,8 +26,7 @@ ServerEventThread::ServerEventThread(plpbus_orb::OrbClient_ptr client,
        _orb_client->receive_event_message("event_listener_started");
 }
 
-void ServerEventThread::run(void* arg)
-{
+void ServerEventThread::run(void* arg) {
        try {
                while(_server_obj->is_shutdown_pending() == 0) {
                        omni_thread::sleep(_interval);
@@ -39,5 +37,7 @@ void ServerEventThread::run(void* arg)
                log_error("server_thread failed, could not connect to client!\n");
        }
        log_debug("server_thread, closing\n");
-       _server_obj->server_thread_closed();
+       if (_server_obj != NULL) {
+               _server_obj->server_thread_closed();
+       }
 }