File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ LOG_MODULE_DECLARE(net_coap, CONFIG_COAP_LOG_LEVEL);
2020#define BLOCK1_OPTION_SIZE 4
2121#define PAYLOAD_MARKER_SIZE 1
2222
23+ static K_MUTEX_DEFINE (coap_client_mutex );
2324static struct coap_client * clients [CONFIG_COAP_CLIENT_MAX_INSTANCES ];
2425static int num_clients ;
2526static K_SEM_DEFINE (coap_client_recv_sem , 0 , 1 ) ;
@@ -1006,7 +1007,9 @@ int coap_client_init(struct coap_client *client, const char *info)
10061007 return - EINVAL ;
10071008 }
10081009
1010+ k_mutex_lock (& coap_client_mutex , K_FOREVER );
10091011 if (num_clients >= CONFIG_COAP_CLIENT_MAX_INSTANCES ) {
1012+ k_mutex_unlock (& coap_client_mutex );
10101013 return - ENOSPC ;
10111014 }
10121015
@@ -1015,6 +1018,7 @@ int coap_client_init(struct coap_client *client, const char *info)
10151018 clients [num_clients ] = client ;
10161019 num_clients ++ ;
10171020
1021+ k_mutex_unlock (& coap_client_mutex );
10181022 return 0 ;
10191023}
10201024
You can’t perform that action at this time.
0 commit comments