Commit bdd0298e authored by Kishen Maloor's avatar Kishen Maloor

oc_tls:Free open CoAP transactions in ..free_peer

This change frees CoAP transactions bound to a peer at the upper
layer following the close of a (D)TLS connection or upon a connection
failure when the (D)TLS peer object is freed. This avoids reestablishing
a connection due to retransmissions of a CONfirmable transaction which is
especially helpful in instances where a (D)TLS session cannot be
established (for e.g. incorrect or expired credentials).

Change-Id: Ic12af03430c31d384f2b4a4d444bdaebe97d006e
Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/29389Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
parent cb18797b
...@@ -1102,10 +1102,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer, ...@@ -1102,10 +1102,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
static void static void
free_client_cb(oc_client_cb_t *cb) free_client_cb(oc_client_cb_t *cb)
{ {
oc_list_remove(client_cbs, cb);
#ifdef OC_BLOCK_WISE #ifdef OC_BLOCK_WISE
oc_blockwise_scrub_buffers_for_client_cb(cb); oc_blockwise_scrub_buffers_for_client_cb(cb);
#endif /* OC_BLOCK_WISE */ #endif /* OC_BLOCK_WISE */
oc_list_remove(client_cbs, cb);
oc_free_string(&cb->uri); oc_free_string(&cb->uri);
if (oc_string_len(cb->query)) { if (oc_string_len(cb->query)) {
oc_free_string(&cb->query); oc_free_string(&cb->query);
......
...@@ -242,3 +242,18 @@ coap_free_all_transactions(void) ...@@ -242,3 +242,18 @@ coap_free_all_transactions(void)
t = next; t = next;
} }
} }
void
coap_free_transaction_by_endpoint(oc_endpoint_t *endpoint)
{
coap_transaction_t *t = (coap_transaction_t *)oc_list_head(transactions_list),
*next;
while (t != NULL) {
next = t->next;
if (oc_endpoint_compare(&t->message->endpoint, endpoint) == 0) {
coap_clear_transaction(t);
break;
}
t = next;
}
}
...@@ -91,6 +91,7 @@ coap_transaction_t *coap_get_transaction_by_mid(uint16_t mid); ...@@ -91,6 +91,7 @@ coap_transaction_t *coap_get_transaction_by_mid(uint16_t mid);
void coap_check_transactions(void); void coap_check_transactions(void);
void coap_free_all_transactions(void); void coap_free_all_transactions(void);
void coap_free_transaction_by_endpoint(oc_endpoint_t *endpoint);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -202,6 +202,8 @@ oc_tls_free_peer(oc_tls_peer_t *peer, bool inactivity_cb) ...@@ -202,6 +202,8 @@ oc_tls_free_peer(oc_tls_peer_t *peer, bool inactivity_cb)
{ {
OC_DBG("\noc_tls: removing peer"); OC_DBG("\noc_tls: removing peer");
coap_free_transaction_by_endpoint(&peer->endpoint);
#ifdef OC_PKI #ifdef OC_PKI
/* Free all roles bound to this (D)TLS session */ /* Free all roles bound to this (D)TLS session */
oc_sec_free_roles(peer); oc_sec_free_roles(peer);
......
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