Commit 3ad8d605 authored by Kishen Maloor's avatar Kishen Maloor

coap/bwt:not clear res buf upon separate response

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 86d25d49
Pipeline #219 passed with stage
in 53 seconds
......@@ -1229,7 +1229,7 @@ oc_ri_find_client_cb_by_token(uint8_t *token, uint8_t token_len)
return cb;
}
static bool
bool
oc_ri_is_client_cb_valid(oc_client_cb_t *client_cb)
{
oc_client_cb_t *cb = oc_list_head(client_cbs);
......@@ -1316,7 +1316,6 @@ oc_ri_invoke_client_cb(void *response, oc_client_cb_t *cb,
struct oc_memb rep_objects = { sizeof(oc_rep_t), 0, 0, 0, 0 };
#endif /* OC_DYNAMIC_ALLOCATION */
oc_rep_set_pool(&rep_objects);
if (payload_len) {
if (cb->discovery) {
if (oc_ri_process_discovery_payload(payload, payload_len, cb->handler,
......@@ -1401,7 +1400,6 @@ oc_ri_invoke_client_cb(void *response, oc_client_cb_t *cb,
}
}
}
return true;
}
......
......@@ -103,7 +103,7 @@ oc_client_cb_t *oc_ri_alloc_client_cb(const char *uri, oc_endpoint_t *endpoint,
oc_client_cb_t *oc_ri_get_client_cb(const char *uri, oc_endpoint_t *endpoint,
oc_method_t method);
bool oc_ri_is_client_cb_valid(oc_client_cb_t *client_cb);
oc_client_cb_t *oc_ri_find_client_cb_by_token(uint8_t *token,
uint8_t token_len);
......
......@@ -702,11 +702,18 @@ coap_receive(oc_message_t *msg)
if (request_buffer) {
request_buffer->ref_count = 0;
}
if (response_buffer) {
response_buffer->ref_count = 0;
}
oc_ri_invoke_client_cb(message, &response_buffer, client_cb,
&msg->endpoint);
/* Do not free the response buffer in case of a separate response
* signal from the server. In this case, the client_cb continues
* to live until the response arrives (or it times out).
*/
if (!oc_ri_is_client_cb_valid(client_cb)) {
if (response_buffer) {
response_buffer->ref_count = 0;
}
}
goto send_message;
#else /* OC_BLOCK_WISE */
oc_ri_invoke_client_cb(message, client_cb, &msg->endpoint);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment