comp-manager: Fixed issue in sending response of Post Request
authorSaurav Babu <saurav.babu@samsung.com>
Fri, 23 Mar 2018 11:18:47 +0000 (16:48 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:49 +0000 (19:38 +0900)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/companion-manager/src/comp_iot.cpp

index 6443abc..1e8553b 100644 (file)
@@ -418,6 +418,8 @@ OCEntityHandlerResult _request_handler(std::shared_ptr<OCResourceRequest> reques
 
                                g_free(arg);
 
+                               pResponse->setRequestHandle(request->getRequestHandle());
+                               pResponse->setResourceHandle(request->getResourceHandle());
                                pResponse->setErrorCode(200);
                                pResponse->setResponseResult(OC_EH_OK);
                                OCPlatform::sendResponse(pResponse);
@@ -498,7 +500,8 @@ static void _clear_user_data(void *user_data)
 }
 
 static void _on_post(const HeaderOptions& /*headerOptions*/,
-                                        const OCRepresentation& rep, const int eCode)
+                                        const OCRepresentation& rep, const int eCode,
+                                        void *user_data)
 {
        last_get_result = eCode;
        int ret;
@@ -513,6 +516,7 @@ static void _on_post(const HeaderOptions& /*headerOptions*/,
                LOG_ERR("Exception %s in on post", e.what());
        }
 
+       _clear_user_data(user_data);
 }
 
 static bool _found_resource(std::shared_ptr<OCResource> resource,
@@ -614,7 +618,9 @@ static bool _found_resource(std::shared_ptr<OCResource> resource,
                                                rep.setValue("data", std::string(cmd->arg1));
 #endif
                                        }
-                                       resource->post(rep, QueryParamsMap(), &_on_post);
+                                       resource->post(rep, QueryParamsMap(),
+                                                  std::bind (&_on_post, std::placeholders::_1,
+                                                  std::placeholders::_2, std::placeholders::_3, cmd));
                                }
                        }