added error handling for iotcon init 13/76913/1
authorkmook <kmook.choi@samsung.com>
Tue, 28 Jun 2016 01:49:06 +0000 (10:49 +0900)
committerkmook <kmook.choi@samsung.com>
Tue, 28 Jun 2016 01:51:57 +0000 (10:51 +0900)
- d2d daemon now does not exit even discovery/service providers fail to initiate

Change-Id: Iaf79842897ab495a0a15b295ec8a5c9ea3198a3c
Signed-off-by: kmook <kmook.choi@samsung.com>
daemon/discovery_mgr_impl.cpp
daemon/discovery_provider/ble_discovery_provider.cpp
daemon/discovery_provider/iotcon_discovery_provider.cpp
daemon/service_mgr_impl.cpp
daemon/service_provider/app_comm_service_provider.cpp
daemon/service_provider/remote_app_control_service_provider.cpp

index 4393728..a3f8cab 100755 (executable)
@@ -43,9 +43,9 @@ conv::discovery_manager_impl::~discovery_manager_impl()
 int conv::discovery_manager_impl::init()
 {
        _D("Discovery_Manager Init!!..");
-       IF_FAIL_RETURN_TAG(register_provider(new(std::nothrow) conv::smartview_discovery_provider()) == CONV_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "smartview_discover_provider register failed");
-       IF_FAIL_RETURN_TAG(register_provider(new(std::nothrow) conv::ble_discovery_provider()) == CONV_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "ble_discovery_provider register failed");
-       IF_FAIL_RETURN_TAG(register_provider(new(std::nothrow) conv::iotcon_discovery_provider()) == CONV_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "iotcon_discovery_provider register failed");
+       register_provider(new(std::nothrow) conv::smartview_discovery_provider());
+       register_provider(new(std::nothrow) conv::ble_discovery_provider());
+       register_provider(new(std::nothrow) conv::iotcon_discovery_provider());
 
        request_map.clear();
        request_timer_map.clear();
@@ -212,18 +212,20 @@ int conv::discovery_manager_impl::register_provider(discovery_provider_base *pro
                return CONV_ERROR_INVALID_PARAMETER;
        }
 
-       provider_list.push_back(provider);
-
        if (provider->set_manager(this) != CONV_ERROR_NONE) {
                _E("Provider set_manager failed");
+               delete provider;
                return CONV_ERROR_INVALID_OPERATION;
        }
 
        if (provider->init() != CONV_ERROR_NONE) {
                _E("Provider initialization failed");
+               delete provider;
                return CONV_ERROR_INVALID_OPERATION;
        }
 
+       provider_list.push_back(provider);
+
        return CONV_ERROR_NONE;
 }
 int conv::discovery_manager_impl::convert_device_into_json(conv::device_iface* device_info, json* json_data)
index abd54a3..c32f655 100755 (executable)
@@ -306,6 +306,7 @@ int start_wfd_discovery(void)
 int conv::ble_discovery_provider::init()
 {
        //init_wfd_client((void*)this);
+       _D("ble_discovery_provider init done");
 
        return CONV_ERROR_NONE;
 }
index b4d596d..e1b1504 100755 (executable)
@@ -51,12 +51,15 @@ int conv::iotcon_discovery_provider::init()
        int ret = iotcon_initialize(CONV_IOTCON_FILEPATH);
        if (ret != IOTCON_ERROR_NONE) {
                _E("Failed iotcon_connect... Error:%d", ret);
+               return CONV_ERROR_INVALID_OPERATION;
        }
 
        if (resource_h_map != NULL)
                delete resource_h_map;
        resource_h_map = new(std::nothrow) resource_h_map_t;
 
+       _D("iotcon_discovery_provider init done");
+
        return CONV_ERROR_NONE;
 }
 
index cfd961e..0e415d4 100755 (executable)
@@ -37,8 +37,8 @@ conv::service_manager_impl::~service_manager_impl()
 
 int conv::service_manager_impl::init()
 {
-       IF_FAIL_RETURN_TAG(register_provider(new(std::nothrow) conv::app_comm_service_provider()) == CONV_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "app_comm_service_provider register failed");
-       IF_FAIL_RETURN_TAG(register_provider(new(std::nothrow) conv::remote_app_control_service_provider()) == CONV_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "remote_app_control_service_provider register failed");
+       register_provider(new(std::nothrow) conv::app_comm_service_provider());
+       register_provider(new(std::nothrow) conv::remote_app_control_service_provider());
 
        register_discovery_info();
        return CONV_ERROR_NONE;
@@ -164,13 +164,14 @@ int conv::service_manager_impl::register_provider(conv::service_provider_base *p
                return CONV_ERROR_INVALID_PARAMETER;
        }
 
-       provider_list.push_back(provider);
-
        if (provider->init() != CONV_ERROR_NONE) {
                _E("Provider initialization failed");
+               delete provider;
                return CONV_ERROR_INVALID_OPERATION;
        }
 
+       provider_list.push_back(provider);
+
        return CONV_ERROR_NONE;
 }
 
index 8771a82..02debf5 100755 (executable)
@@ -33,6 +33,7 @@ conv::app_comm_service_provider::~app_comm_service_provider()
 
 int conv::app_comm_service_provider::init()
 {
+       _D("app_comm_service_provider init done");
        return CONV_ERROR_NONE;
 }
 
index 0f27281..c57bdee 100755 (executable)
@@ -284,10 +284,11 @@ int conv::remote_app_control_service_provider::init()
        error = iotcon_resource_create(CONV_URI_SMARTVIEW_REMOTE_APP_CONTROL, resource_types, resource_ifaces, properties, iotcon_request_cb, NULL, &iotcon_resource);
        IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource creation failed");
 
-
        iotcon_resource_types_destroy(resource_types);
        iotcon_resource_interfaces_destroy(resource_ifaces);
 
+       _D("remote_app_control_service_provider init done");
+
        return CONV_ERROR_NONE;
 }