@@ -81,14 +81,24 @@ static coap_transaction_t *transaction_create(void)
81
81
82
82
return this ;
83
83
}
84
+
85
+ static void transaction_free (coap_transaction_t * this )
86
+ {
87
+ if (!this ) {
88
+ return ;
89
+ }
90
+
91
+ if (this -> data_ptr ) {
92
+ ns_dyn_mem_free (this -> data_ptr );
93
+ }
94
+ ns_dyn_mem_free (this );
95
+ }
96
+
84
97
void transaction_delete (coap_transaction_t * this )
85
98
{
86
99
if (this ) {
87
100
ns_list_remove (& request_list , this );
88
- if (this -> data_ptr ){
89
- ns_dyn_mem_free (this -> data_ptr );
90
- }
91
- ns_dyn_mem_free (this );
101
+ transaction_free (this );
92
102
}
93
103
94
104
return ;
@@ -99,11 +109,12 @@ void transactions_delete_all(uint8_t *address_ptr, uint16_t port)
99
109
coap_transaction_t * transaction = transaction_find_by_address (address_ptr , port );
100
110
101
111
while (transaction ) {
112
+ ns_list_remove (& request_list , transaction );
102
113
if (transaction -> resp_cb ) {
103
114
transaction -> resp_cb (transaction -> service_id , address_ptr , port , NULL );
104
115
}
105
116
sn_coap_protocol_delete_retransmission (coap_service_handle -> coap , transaction -> msg_id );
106
- transaction_delete (transaction );
117
+ transaction_free (transaction );
107
118
transaction = transaction_find_by_address (address_ptr , port );
108
119
}
109
120
}
@@ -113,17 +124,22 @@ static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_
113
124
coap_transaction_t * this = NULL ;
114
125
(void )address_ptr ;
115
126
(void )param ;
116
- tr_warn ("transaction was not handled" );
127
+ tr_warn ("transaction was not handled %d" , resp_ptr -> msg_id );
117
128
if (!resp_ptr ) {
118
129
return -1 ;
119
130
}
120
131
if ( resp_ptr -> token_ptr ){
121
132
this = transaction_find_client_by_token (resp_ptr -> token_ptr );
122
133
}
123
- if (this && this -> resp_cb ) {
134
+ if (!this ) {
135
+ return 0 ;
136
+ }
137
+
138
+ ns_list_remove (& request_list , this );
139
+ if (this -> resp_cb ) {
124
140
this -> resp_cb (this -> service_id , address_ptr -> addr_ptr , address_ptr -> port , NULL );
125
141
}
126
- transaction_delete (this );
142
+ transaction_free (this );
127
143
return 0 ;
128
144
}
129
145
@@ -250,11 +266,12 @@ int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t
250
266
return -1 ;
251
267
}
252
268
tr_debug ("Service %d, response received" , this -> service_id );
269
+ ns_list_remove (& request_list , this );
253
270
if (this -> resp_cb ) {
254
271
this -> resp_cb (this -> service_id , (uint8_t * )source_addr_ptr , port , coap_message );
255
272
}
256
273
sn_coap_parser_release_allocated_coap_msg_mem (handle -> coap , coap_message );
257
- transaction_delete (this );
274
+ transaction_free (this );
258
275
}
259
276
260
277
return 0 ;
0 commit comments