changed discovery_stop() to call discovery_cb function 15/80415/1
authorkmook <kmook.choi@samsung.com>
Mon, 18 Jul 2016 04:37:05 +0000 (13:37 +0900)
committerkmook <kmook.choi@samsung.com>
Mon, 18 Jul 2016 04:37:05 +0000 (13:37 +0900)
Change-Id: I439f84b9ed06d6f084fd4d42019177b405275404
Signed-off-by: kmook <kmook.choi@samsung.com>
daemon/discovery_mgr_impl.cpp

index a587c6d..5884ef4 100755 (executable)
@@ -76,6 +76,7 @@ int conv::discovery_manager_impl::notify_time_up(std::string client)
        // 1. When no client is using discovery, it should be stopped
        _D("notify_time_up.. with current discovery count :%d", count_discovery_request);
        if (--count_discovery_request <= 0) {
+               count_discovery_request = 0;
                stop_discovery();
        }
 
@@ -179,9 +180,16 @@ int conv::discovery_manager_impl::handle_request(request* request_obj)
 
                        request_obj->reply(CONV_ERROR_NONE);
                } else if ( !strcmp(request_obj->get_subject(), CONV_SUBJECT_DISCOVERY_STOP) ){
-                       stop_discovery();
+                       const char* client = request_obj->get_sender();
+
+                       if (count_discovery_request<=0) {
+                               _D("discovery is already stopped");
+                               request_obj->reply(CONV_ERROR_INVALID_OPERATION);
+                       } else {
+                               notify_time_up(client);
+                               request_obj->reply(CONV_ERROR_NONE);
+                       }
 
-                       request_obj->reply(CONV_ERROR_NONE);
                        delete request_obj;
                }