Skip to content

Commit 61ecb6b

Browse files
author
Tero Heinonen
authored
Session cleanup timer fixes (ARMmbed#105)
Fixed session cleanup timer bugs: - secure session exec interval operator logic fixed - changed ns_list_foreach to ns_list_foreach_safe in session delete loop
1 parent cbe656a commit 61ecb6b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: source/coap_connection_handler.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ void coap_connection_handler_exec(uint32_t time)
10011001
{
10021002
if(ns_list_count(&secure_session_list)){
10031003
// Seek & destroy old sessions where close notify have been sent
1004-
ns_list_foreach(secure_session_t, cur_ptr, &secure_session_list) {
1004+
ns_list_foreach_safe(secure_session_t, cur_ptr, &secure_session_list) {
10051005
if(cur_ptr->session_state == SECURE_SESSION_CLOSED) {
10061006
if((cur_ptr->last_contact_time + CLOSED_SECURE_SESSION_TIMEOUT) <= time){
10071007
secure_session_delete(cur_ptr);

Diff for: source/coap_service_api.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ static void service_event_handler(arm_event_s *event)
201201
tr_debug("service tasklet initialised");
202202
/*initialize coap service and listen socket*/
203203
}
204+
204205
if (event->event_type == ARM_LIB_SYSTEM_TIMER_EVENT && event->event_id == COAP_TICK_TIMER) {
205206
coap_message_handler_exec(coap_service_handle, coap_ticks++);
206-
if(coap_ticks && !coap_ticks % SECURE_SESSION_CLEAN_INTERVAL){
207+
if(coap_ticks && !(coap_ticks % SECURE_SESSION_CLEAN_INTERVAL)){
207208
coap_connection_handler_exec(coap_ticks);
208209
}
209210
}

0 commit comments

Comments
 (0)