Skip to content

Commit ae4d9db

Browse files
author
Tero Heinonen
authored
Call transaction callback when transactions are deleted (#48)
When secure session is deleted, transaction callback must be called to inform request sender that response is not going to be received.
1 parent 0480a02 commit ae4d9db

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

source/coap_connection_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
9595
static void secure_session_delete(secure_session_t *this)
9696
{
9797
if (this) {
98-
transactions_delete_all(this->remote_host.address, this->remote_host.identifier);
9998
ns_list_remove(&secure_session_list, this);
99+
transactions_delete_all(this->remote_host.address, this->remote_host.identifier);
100100
if( this->sec_handler ){
101101
coap_security_destroy(this->sec_handler);
102102
this->sec_handler = NULL;
@@ -529,7 +529,7 @@ static void secure_recv_sckt_msg(void *cb_res)
529529
socket_callback_t *sckt_data = cb_res;
530530
internal_socket_t *sock = int_socket_find_by_socket_id(sckt_data->socket_id);
531531
ns_address_t src_address;
532-
uint8_t dst_address[16];
532+
uint8_t dst_address[16] = {0};
533533
memset(&src_address, 0, sizeof(ns_address_t));
534534

535535
if (sock && read_data(sckt_data, sock, &src_address, dst_address) == 0) {

source/coap_message_handler.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ void transactions_delete_all(uint8_t *address_ptr, uint16_t port)
9999
coap_transaction_t *transaction = transaction_find_by_address(address_ptr, port);
100100

101101
while (transaction) {
102+
if (transaction->resp_cb) {
103+
transaction->resp_cb(transaction->service_id, address_ptr, port, NULL);
104+
}
102105
sn_coap_protocol_delete_retransmission(coap_service_handle->coap, transaction->msg_id);
103106
transaction_delete(transaction);
104107
transaction = transaction_find_by_address(address_ptr, port);

0 commit comments

Comments
 (0)