Commit 4a84ea85 authored by Kishen Maloor's avatar Kishen Maloor

Fix circular dep in freeing transaction/TLS ctxt

Change-Id: I23ad3532b416b9952910084ae1e7091f6d128ae2
Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/29393Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
parent a95024d7
......@@ -155,19 +155,11 @@ coap_send_transaction(coap_transaction_t *t)
} else {
/* timed out */
OC_WRN("Timeout");
#ifdef OC_SERVER
OC_WRN("timeout.. so removing observers");
/* handle observers */
/* remove observers */
coap_remove_observer_by_client(&t->message->endpoint);
#endif /* OC_SERVER */
#ifdef OC_SECURITY
if (t->message->endpoint.flags & SECURED) {
oc_tls_close_connection(&t->message->endpoint);
}
#endif /* OC_SECURITY */
#ifdef OC_CLIENT
oc_ri_remove_client_cb_by_mid(t->mid);
#endif /* OC_CLIENT */
......@@ -175,9 +167,15 @@ coap_send_transaction(coap_transaction_t *t)
#ifdef OC_BLOCK_WISE
oc_blockwise_scrub_buffers();
#endif /* OC_BLOCK_WISE */
#ifdef OC_SECURITY
if (t->message->endpoint.flags & SECURED) {
oc_tls_close_connection(&t->message->endpoint);
} else
#endif /* OC_SECURITY */
{
coap_clear_transaction(t);
}
}
} else {
oc_message_add_ref(t->message);
......@@ -225,7 +223,12 @@ coap_check_transactions(void)
if (oc_etimer_expired(&t->retrans_timer)) {
++(t->retrans_counter);
OC_DBG("Retransmitting %u (%u)", t->mid, t->retrans_counter);
int removed = oc_list_length(transactions_list);
coap_send_transaction(t);
if ((removed - oc_list_length(transactions_list)) > 1) {
t = (coap_transaction_t *)oc_list_head(transactions_list);
continue;
}
}
t = next;
}
......@@ -246,13 +249,20 @@ coap_free_all_transactions(void)
void
coap_free_transaction_by_endpoint(oc_endpoint_t *endpoint)
{
#ifdef OC_SERVER
/* remove all observations by this peer */
coap_remove_observer_by_client(endpoint);
#endif /* OC_SERVER */
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) {
#ifdef OC_CLIENT
/* Remove the client callback tied to this transaction */
oc_ri_remove_client_cb_by_mid(t->mid);
#endif /* OC_CLIENT */
coap_clear_transaction(t);
break;
}
t = next;
}
......
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