@@ -112,6 +112,7 @@ static void clear_secure_sessions(internal_socket_t *this){
112
112
if ( this ){
113
113
ns_list_foreach_safe (secure_session_t , cur_ptr , & secure_session_list ) {
114
114
if ( cur_ptr -> parent == this ){
115
+ coap_security_send_close_alert ( cur_ptr -> sec_handler );
115
116
secure_session_delete (cur_ptr );
116
117
}
117
118
}
@@ -579,34 +580,17 @@ coap_conn_handler_t *connection_handler_create(receive_from_socket_cb *recv_from
579
580
void connection_handler_destroy (coap_conn_handler_t * handler )
580
581
{
581
582
if (handler ){
582
- if ( handler -> socket && handler -> socket -> is_secure ){
583
- //If nothing is sent, there is no address to find.
584
- //This case is handled in int_socket_delete.
585
- secure_session_t * session = secure_session_find_by_parent ( handler -> socket );
586
-
587
- while (session != NULL ){
588
- if ( session && handler -> socket -> usage_counter == 1 ){ //Last connection
589
- coap_security_send_close_alert ( session -> sec_handler );
590
- }
591
-
592
- if ( session ){
593
- secure_session_delete (session );
594
- }
595
- session = secure_session_find_by_parent ( handler -> socket );
596
- }
597
- }
598
583
int_socket_delete (handler -> socket );
599
584
handler -> socket = NULL ;
600
585
ns_dyn_mem_free (handler );
601
586
}
602
587
}
603
588
604
- void connection_handler_close_secure_connection ( coap_conn_handler_t * handler , ns_address_t * dest_addr )
589
+ void connection_handler_close_secure_connection ( coap_conn_handler_t * handler , uint8_t destination_addr_ptr [ static 16 ], uint16_t port )
605
590
{
606
591
if (handler ){
607
592
if ( handler -> socket && handler -> socket -> is_secure ){
608
- secure_session_t * session = secure_session_find ( handler -> socket , dest_addr -> address ,
609
- dest_addr -> identifier );
593
+ secure_session_t * session = secure_session_find ( handler -> socket , destination_addr_ptr , port );
610
594
if ( session ){
611
595
coap_security_send_close_alert ( session -> sec_handler );
612
596
}
0 commit comments