@@ -175,6 +175,7 @@ static secure_session_t *secure_session_create(internal_socket_t *parent, const
175
175
}
176
176
}
177
177
if (!to_be_removed ){
178
+ tr_err ("max session count exceeded" );
178
179
return NULL ;
179
180
}
180
181
@@ -188,6 +189,7 @@ static secure_session_t *secure_session_create(internal_socket_t *parent, const
188
189
}
189
190
}
190
191
if (handshakes >= max_handshakes ) {
192
+ tr_err ("ongoing handshakes exceeded" );
191
193
return NULL ;
192
194
}
193
195
@@ -215,6 +217,7 @@ static secure_session_t *secure_session_create(internal_socket_t *parent, const
215
217
this -> sec_handler = coap_security_create (parent -> socket , this -> timer .id , this , secure_mode ,
216
218
& secure_session_sendto , & secure_session_recvfrom , & start_timer , & timer_status );
217
219
if ( !this -> sec_handler ){
220
+ tr_err ("security create failed" );
218
221
ns_dyn_mem_free (this );
219
222
return NULL ;
220
223
}
@@ -647,9 +650,11 @@ static void secure_recv_sckt_msg(void *cb_res)
647
650
session -> last_contact_time = coap_service_get_internal_timer_ticks ();
648
651
// Start handshake
649
652
if (!coap_security_handler_is_started (session -> sec_handler )) {
650
- coap_security_handler_connect_non_blocking (session -> sec_handler , true, DTLS , keys , sock -> timeout_min , sock -> timeout_max );
653
+ if (-1 == coap_security_handler_connect_non_blocking (session -> sec_handler , true, DTLS , keys , sock -> timeout_min , sock -> timeout_max )) {
654
+ tr_err ("Connection start failed" );
655
+ secure_session_delete (session );
656
+ }
651
657
ns_dyn_mem_free (keys ._key );
652
-
653
658
}
654
659
} else {
655
660
//Continue handshake
@@ -742,11 +747,16 @@ int coap_connection_handler_virtual_recv(coap_conn_handler_t *handler, uint8_t a
742
747
if (sock -> parent -> _get_password_cb && 0 == sock -> parent -> _get_password_cb (sock -> socket , address , port , & keys )) {
743
748
session = secure_session_create (sock , address , port , keys .mode );
744
749
if (!session ) {
745
- tr_err ("coap_connection_handler_virtual_recv session creation failed - OOM " );
750
+ tr_err ("coap_connection_handler_virtual_recv session creation failed" );
746
751
ns_dyn_mem_free (keys ._key );
747
752
return -1 ;
748
753
}
749
- coap_security_handler_connect_non_blocking (session -> sec_handler , true, DTLS , keys , handler -> socket -> timeout_min , handler -> socket -> timeout_max );
754
+ if (-1 == coap_security_handler_connect_non_blocking (session -> sec_handler , true, DTLS , keys , handler -> socket -> timeout_min , handler -> socket -> timeout_max )) {
755
+ tr_err ("Connection start failed" );
756
+ ns_dyn_mem_free (keys ._key );
757
+ secure_session_delete (session );
758
+ return -1 ;
759
+ }
750
760
ns_dyn_mem_free (keys ._key );
751
761
return 0 ;
752
762
} else {
0 commit comments