From 3ffe72650b7820e697bce01bbf75041d271b3fb0 Mon Sep 17 00:00:00 2001 From: Jaewook Jung Date: Mon, 25 Apr 2016 16:37:02 +0900 Subject: [PATCH] add removing BWT data when retransmission fails When retransmission fails(time out), the data in BWT list has to be removed. Change-Id: Ic94b5f2c8c25604b237383939f31bd30412bb1f9 Signed-off-by: Jaewook Jung Reviewed-on: https://gerrit.iotivity.org/gerrit/7901 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- .../csdk/connectivity/inc/cablockwisetransfer.h | 12 ++++++---- .../csdk/connectivity/src/cablockwisetransfer.c | 27 ++++++++++++++++++++++ resource/csdk/connectivity/src/camessagehandler.c | 12 ++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/resource/csdk/connectivity/inc/cablockwisetransfer.h b/resource/csdk/connectivity/inc/cablockwisetransfer.h index 24bab6c..51677e6 100644 --- a/resource/csdk/connectivity/inc/cablockwisetransfer.h +++ b/resource/csdk/connectivity/inc/cablockwisetransfer.h @@ -557,12 +557,14 @@ CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID); CAResult_t CARemoveAllBlockDataFromList(); /** - * Check if data exist in block-wise transfer list. - * @param[in] blockID ID set of CABlockData. - * @return true or false. + * Find the block data with seed info and remove it from block-wise transfer list. + * @param[in] token token of the message. + * @param[in] tokenLength token length of the message. + * @param[in] portNumber port. + * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h). */ -bool CAIsBlockDataInList(const CABlockDataID_t *blockID); - +CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength, + uint16_t portNumber); #ifdef __cplusplus } /* extern "C" */ diff --git a/resource/csdk/connectivity/src/cablockwisetransfer.c b/resource/csdk/connectivity/src/cablockwisetransfer.c index e0d65af..f94e9e4 100644 --- a/resource/csdk/connectivity/src/cablockwisetransfer.c +++ b/resource/csdk/connectivity/src/cablockwisetransfer.c @@ -2719,3 +2719,30 @@ void CALogBlockInfo(coap_block_t *block) OIC_LOG_V(DEBUG, TAG, "block option-szx : %d", block->szx); } + +CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength, + uint16_t portNumber) +{ + CABlockDataID_t* blockDataID = CACreateBlockDatablockId(token, tokenLength, portNumber); + if (NULL == blockDataID || blockDataID->idLength < 1) + { + OIC_LOG(ERROR, TAG, "blockId is null"); + CADestroyBlockID(blockDataID); + return CA_STATUS_FAILED; + } + + CAResult_t res = CA_STATUS_OK; + + if (NULL != CAGetBlockDataFromBlockDataList(blockDataID)) + { + res = CARemoveBlockDataFromList(blockDataID); + if (CA_STATUS_OK != res) + { + OIC_LOG(ERROR, TAG, "CARemoveBlockDataFromList failed"); + } + } + + CADestroyBlockID(blockDataID); + + return res; +} diff --git a/resource/csdk/connectivity/src/camessagehandler.c b/resource/csdk/connectivity/src/camessagehandler.c index e2eb295..e637642 100644 --- a/resource/csdk/connectivity/src/camessagehandler.c +++ b/resource/csdk/connectivity/src/camessagehandler.c @@ -297,6 +297,18 @@ static void CATimeoutCallback(const CAEndpoint_t *endpoint, const void *pdu, uin cadata->requestInfo = NULL; cadata->responseInfo = resInfo; +#ifdef WITH_BWT + if (CAIsSupportedBlockwiseTransfer(endpoint->adapter)) + { + res = CARemoveBlockDataFromListWithSeed(resInfo->info.token, resInfo->info.tokenLength, + endpoint->port); + if (CA_STATUS_OK != res) + { + OIC_LOG(ERROR, TAG, "CARemoveBlockDataFromListWithSeed failed"); + } + } +#endif // WITH_BWT + #ifdef SINGLE_THREAD CAProcessReceivedData(cadata); #else -- 2.7.4