mirror of https://github.com/ARMmbed/mbed-os.git
Add a flag to maintain backward compatibility
By default CoAP will create a copy of the whole data to be passed to application and it keeps the backward compatibility. If enabled, application must NOT free the payload when it gets the COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED status. And application must call sn_coap_protocol_block_remove() instead.pull/11359/head
parent
d74326e5cc
commit
5f92db3c12
|
@ -1,24 +1,18 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [v5.1.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.0)
|
||||||
|
|
||||||
|
- Introduce SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT configuration flag.
|
||||||
|
Flag is disabled by default to keep the backward compatibility in place.
|
||||||
|
If flag is enabled, application must NOT free the payload when it gets the COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED status.
|
||||||
|
And application must call sn_coap_protocol_block_remove() instead.
|
||||||
|
|
||||||
|
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v5.0.0...v5.1.0)
|
||||||
|
|
||||||
## [v5.0.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.0.0)
|
## [v5.0.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.0.0)
|
||||||
**NOTE! Blockwise functionality has changed and it is not backward compatible. User is now responsible of freeing the data by calling sn_coap_protocol_block_remove() and must NOT free the payload anymore separately.**
|
|
||||||
|
|
||||||
Here is the change needed on application side:
|
|
||||||
|
|
||||||
```
|
|
||||||
if (received_coap_message->coap_status == COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED) {
|
|
||||||
free(received_coap_header->payload_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
if (received_coap_message->coap_status == COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED) {
|
|
||||||
// Free the block message from the CoAP list
|
|
||||||
sn_nsdl_remove_coap_block(_nsdl_handle, address, received_coap_header->payload_len, received_coap_header->payload_ptr);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- Reduce heap footprint by storing only single block when receiving a blockwise message.
|
- Reduce heap footprint by storing only single block when receiving a blockwise message.
|
||||||
|
* User is now responsible of freeing the data by calling sn_coap_protocol_block_remove() and must not free the payload separately.
|
||||||
- Bug fix: Request blockwise transfer if incoming payload length is too large and when it comes without block indication.
|
- Bug fix: Request blockwise transfer if incoming payload length is too large and when it comes without block indication.
|
||||||
|
|
||||||
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.8.1...v5.0.0)
|
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.8.1...v5.0.0)
|
||||||
|
@ -250,4 +244,3 @@ Extend blockwise message transfer status to have states for sending as well.
|
||||||
**New feature**
|
**New feature**
|
||||||
|
|
||||||
- Initial release of mbed-coap separated from mbed-client-c
|
- Initial release of mbed-coap separated from mbed-client-c
|
||||||
|
|
||||||
|
|
|
@ -260,4 +260,14 @@
|
||||||
#define SN_COAP_BLOCKWISE_INTERNAL_BLOCK_2_HANDLING_ENABLED 1
|
#define SN_COAP_BLOCKWISE_INTERNAL_BLOCK_2_HANDLING_ENABLED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \def SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT
|
||||||
|
* \brief A heap optimization switch, which removes unnecessary copy of the blockwise data.
|
||||||
|
* If enabled, application must NOT free the payload when it gets the COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED status.
|
||||||
|
* Application must call sn_coap_protocol_block_remove() instead.
|
||||||
|
*/
|
||||||
|
#ifndef SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT
|
||||||
|
#define SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT 0 /**< Disabled by default */
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // SN_CONFIG_H
|
#endif // SN_CONFIG_H
|
||||||
|
|
|
@ -2293,8 +2293,18 @@ static bool sn_coap_handle_last_blockwise(struct coap_s *handle, const sn_nsdl_a
|
||||||
if (!whole_payload_len) {
|
if (!whole_payload_len) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT
|
||||||
received_coap_msg_ptr->payload_ptr = payload_ptr;
|
received_coap_msg_ptr->payload_ptr = payload_ptr;
|
||||||
received_coap_msg_ptr->payload_len = whole_payload_len;
|
received_coap_msg_ptr->payload_len = whole_payload_len;
|
||||||
|
#else
|
||||||
|
received_coap_msg_ptr->payload_ptr = sn_coap_protocol_malloc_copy(handle, payload_ptr, whole_payload_len);
|
||||||
|
if (received_coap_msg_ptr->payload_ptr == NULL) {
|
||||||
|
tr_error("sn_coap_handle_last_blockwise - failed to allocate whole package!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
received_coap_msg_ptr->payload_len = whole_payload_len;
|
||||||
|
#endif
|
||||||
received_coap_msg_ptr->coap_status = COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED;
|
received_coap_msg_ptr->coap_status = COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue